Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>The Element Object</h1>
<h2>The childNodes Property</h2>
<div id="myDIV" style="background:coral; padding:16px;">
  <p>First p element (index 1)</p>
  <p>Second p element (index 3)</p>
</div>
<p>The number of child nodes in "myDIV" are:</p>
<p id="demo"></p>
<p>Whitespace between elements are text nodes. In this example, index 0, 2 and 4 in "myDIV" are text nodes.</p>
<script>
const element = document.getElementById("myDIV");
let numb = element.childNodes.length;
document.getElementById("demo").innerHTML = numb;
</script>
</body>
</html>