Element nodeName Property - Get the node names of the <body> element's child nodes: - Javascript DOM

Javascript examples for DOM:Element nodeName

Description

Element nodeName Property - Get the node names of the <body> element's child nodes:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials