It only takes the id name of the tag and returns the number of elements in the tag.
In the following example, there are two elements in the div tag. Using the property "childElementCount" the number of elements was found out and the result is displayed in the output.
<html> <body> <div id="DIV"> <p>First element</p> <p>Second element</p> </div> <p id = "cou"></p> <script> var cou = document.getElementById("DIV").childElementCount; document.getElementById("cou").innerHTML = "number of elements :" +" "+ cou; </script> </body> </html>
First element Second element number of elements : 2