6 const editingHost
= document
.querySelectorAll("div[contenteditable]");
7 // For emulating the traditional behavior, collapse Selection to end of the
8 // last <div contenteditable> which is the deepest last child of the <body>.
9 getSelection().collapse(editingHost
[1], editingHost
[1].childNodes
.length
);
10 getSelection().removeAllRanges();
11 const r
= document
.createRange();
12 r
.setStart(editingHost
[0], 1);
13 r
.setEnd(editingHost
[1], 0);
14 getSelection().addRange(r
);
15 document
.execCommand("insertOrderedList");
20 <body onload=
"onLoad();"><div contenteditable
>a
</div><div contenteditable
></div></body>