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

<h1>Document 对象</h1>

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

<p>创建 button 元素:</p>

<script>
const btn = document.createElement("button");
btn.innerHTML = "Hello Button";
document.body.appendChild(btn);
</script>

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