<!DOCTYPE html> <html> <body> <h1>Document 对象</h1> <h2>createElement() 方法</h2> <p>创建一个 p 元素并将其追加到 "myDiv":</p> <div id="myDIV" style="padding:16px;background-color:lightgray"> <h3>DIV 元素</h3> </div> <script> // 创建元素: const para = document.createElement("p"); para.innerHTML = "This is a paragraph."; // 追加到另一个元素: document.getElementById("myDIV").appendChild(para); </script> </body> </html>