<!DOCTYPE html>
<html lang="en-US">
<body>
<div>
<h1>Heading</h1>
<p>Paragraph</p>
</div>
<p>Click on the button to count the number of child nodes inside div tag</p>
<button onclick="myFunction()">Click</button>
<p id="point"></p>
<script>
var x = document.getElementById("point");
var node = document.getElementsByTagName("div")[0];
function myFunction(){
x.innerHTML = node.children.length;
}
</script> </body>
</html>