<!DOCTYPE html>
<
html
>
<
head
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
/>
<
title
>GeeksForGeeks | HTML DOM Normalize Method</
title
>
</
head
>
<
body
>
<
script
type
=
"text/javascript"
>
var parent = document.createElement("div");
parent.appendChild(document.createTextNode("Child 1 "));
parent.appendChild(document.createTextNode("Child 2 "));
parent.appendChild(document.createTextNode("Child 3"));
// Here the length of parent's child nodes would be 3,
// you can check the same
// using parent.childNodes.length.
alert('Before Normalize : child nodes length: ' +
parent.childNodes.length);
parent.normalize();
document.body.appendChild(parent);
// Now, parent.childNodes.length === 1
// Content of all 3 childs nodes
// are in one child node only.
alert('After Normalize : child nodes length: ' +
parent.childNodes.length);
</
script
>
</
body
>
</
html
>