<!DOCTYPE html>
<html>
<body onload="normPara()">
<h1>The Document Object</h1>
<h2>The normalize() Method</h2>
<button onclick="addTextNode()">Add a Text Node</button>
<button onclick="normPara()">Normalize the Document</button>
<p>The document has <span id="cc" style="font-size:20px">1</span> child node(s).</p>
<script>
function addTextNode() {
const textNode= document.createTextNode("Click again. ");
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>