insertparagraph-in-editable-dl-outside-body.html (508B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <script> 6 "use strict"; 7 8 document.addEventListener("DOMContentLoaded", () => { 9 const dl = document.createElement("dl"); 10 const dd = document.createElement("dd"); 11 const p = document.createElement("p"); 12 dd.appendChild(p); 13 dl.appendChild(dd); 14 document.documentElement.appendChild(dl); 15 dl.contentEditable = true; 16 getSelection().collapse(p, 0); 17 document.execCommand("insertParagraph"); 18 }, {once: true}); 19 </script> 20 </head> 21 <body></body> 22 </html>