3 const button
= document
.querySelector("button");
4 // For emulating the traditional behavior, collapse Selection to end of the
5 // <button> which is the deepest last child of the <body>.
6 getSelection().collapse(button
, button
.childNodes
.length
);
7 document
.execCommand("styleWithCSS", false, true);
8 document
.execCommand("delete");
9 document
.querySelector("ul[contenteditable]")
10 .addEventListener("DOMNodeRemoved", () => {
11 const range
= document
.createRange();
12 range
.setEndAfter(button
);
13 getSelection().addRange(range
);
14 getSelection().deleteFromDocument();
16 document
.execCommand("outdent");
19 <body onload=
"onLoad()">
20 <ul contenteditable
style=
"margin: -1px 0px 1px 6px">
23 <button></button>></dd></ul></body>