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

Javascript examples for DOM:Element nodeName

Description

Element nodeName Property - Get the node types 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() {/*w w w. ja  va  2  s . c om*/
    var c = document.body.childNodes;
    var txt = "";
    var i;
    for (i = 0; i < c.length; i++) {
        txt = txt + c[i].nodeType + "<br>";
    }

    document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>

Related Tutorials