代码示例:(标识:jsck_document_createelement_1)
<!DOCTYPE html>
<html>
<body>

<h1>Document 对象</h1>

<h2>createElement() 方法</h2>

<p>创建带一些文本的 p 元素:</p>

<script>
// 创建元素:
const para = document.createElement("p");
para.innerText = "This is a paragraph.";

// 追加到 body:
document.body.appendChild(para);
</script>

</body>
</html>
运行结果: