Javascript examples for DOM:Element nodeName
Element nodeName Property - Get the node names of the <body> element's child nodes:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <!-- My personal comment goes here.. --> <p id="demo"></p> <script> function myFunction() {//from ww w . j ava 2 s . co m var c = document.body.childNodes; var txt = ""; var i; for (i = 0; i < c.length; i++) { txt = txt + c[i].nodeName + "<br>"; } document.getElementById("demo").innerHTML = txt; } </script> </body> </html>