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

<body onload="normPara()">

<h1>Document 对象</h1>

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

<button onclick="addTextNode()">添加文本节点</button>

<button onclick="normPara()">规范化此文档</button>

<p>此文档拥有 <span id="cc" style="font-size:20px">1</span> 个子节点。</p>

<script>
function addTextNode() {
const textNode= document.createTextNode("再次点击。");
const body = document.body;
body.appendChild(textNode);
const cc = document.getElementById("cc");
  cc.innerHTML = body.childNodes.length;
}

function normPara() {
  document.normalize();
  const body = document.body;
  const cc = document.getElementById("cc");
  cc.innerHTML = body.childNodes.length;
}
</script>

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