Download Source Code Aplikasi

Normalizedocument()

Monday, November 11th, 2019 - DOM » Document

Metode Document.normalizeDocument() (Core Level 3) memiliki fungsi yang sama menyerupai Node.normalize(), ialah “menormalkan”.

Sintaks:

document.normalizeDocument()

Penggunaan Document.normalize() akan berdampak pada banyaknya child node, dan juga membersihkan hirarki node yang tersarang.

Contoh:

<DIV></DIV> <SCRIPT TYPE="text/javascript"> var pElemNode = document.createElement("p"); var textNodeGood = document.createTextNode("Good"); var textNodeMorning = document.createTextNode(" Morning"); pElemNode.appendChild(textNodeGood); pElemNode.appendChild(textNodeMorning); var divElem = document.getElementsByTagName("div")[0]; divElem.appendChild(pElemNode); var pElem = document.getElementsByTagName("p")[0]; alert(pElem.childNodes.length); // 2 document.normalize(); alert(pElem.childNodes.length); //1 </SCRIPT>

Sebelum dinormalkan:

<P> "Good" " Morning" </P>

Sesudah dinormalkan:

<P>Good Morning</P>

Untuk melihat kerja metode Document.normalizeDocument(), anda dapat gunakan FF1+, NN8+.

Demikian yang dapat kami share kepada sobat source code aplikasi pada kesempatan ini, semoga dapat bermanfaat dan bisa menjadi referensi pemrograman bagi anda. Jangan lupa like Fan Page kami, dan SUBSCRIBE Channel Youtube kami untuk dapatkan update source code aplikasi terbaru.
Download Source Code Aplikasi
Normalizedocument() | Ahmad Code | 4.5