31 lines
804 B
HTML
31 lines
804 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
const table = document.querySelector("table");
|
|
// For emulating traditional behavior, collapse Selection to end of the
|
|
// text node after the <p> (<table> does not close the <p>).
|
|
getSelection().collapse(
|
|
document.body.lastChild,
|
|
document.body.lastChild.length
|
|
);
|
|
const paragraph = document.querySelector("p");
|
|
document.documentElement.contentEditable = true;
|
|
getSelection().setBaseAndExtent(document, 0, document.documentElement, 1);
|
|
paragraph.contentEditable = false;
|
|
table.insertRow(0);
|
|
document.execCommand("forwardDelete");
|
|
});
|
|
</script>
|
|
</head>
|
|
<p>
|
|
<del>
|
|
<button contenteditable>
|
|
</button>
|
|
<table>
|
|
</table>
|
|
</del>
|
|
</p>
|
|
</body>
|
|
</html>
|