Element nodeValue Property - Get the node name, node value and the node type of the <div> element's first child node: - Javascript DOM

Javascript examples for DOM:Element nodeValue

Description

Element nodeValue Property - Get the node name, node value and the node type of the <div> element's first child node:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDIV">This is a div element.</div>
<br>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w w w. j  a va2s .com*/
    var x = document.getElementById("myDIV").firstChild;
    var txt = "";
    txt += "The node name: " + x.nodeName + "<br>";
    txt += "The node value: " + x.nodeValue + "<br>";
    txt += "The node type: " + x.nodeType;
    document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>

Related Tutorials