Javascript examples for DOM:Element NodeList
Element NodeList Property - Return the number of child nodes of the <body> element:
<!DOCTYPE html> <html> <body><!-- This is a comment node! --> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . ja va 2 s . c om*/ var nodelist = document.body.childNodes.length; document.getElementById("demo").innerHTML = nodelist; } </script> </body> </html>