<html>
<head>
<style>
div {
border: 1px solid black;
margin: 5px;
}
</style>
</head>
<body>
<p>Click the button to find out how many child nodes the div element below has.</p>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">
<p>First p element (index 1)</p>
<p>Second p element (index 3)</p>
</div>
<p><strong>Note:</strong> Whitespace inside elements is considered as text, and text
is considered as nodes. In this example, index 0, 2 and 4 in DIV are text nodes.</p>
<p id="demo"></p>
<script>
function myFunction() {
var c = document.getElementById("myDIV").childNodes.length;
document.getElementById("demo").innerHTML = c;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_node_childnodes_length by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 03:02:17 GMT -->
</html>