The DOM childElementCount property is used to count the number of child element and return it. It counts only child element except for text and comment nodes.
Syntax:
node.childElementCount
Where node is an object which represents the document or element.
Return Value: It returns the number of child elements of the given element.
Example:
<!DOCTYPE html> <html> <head> <title> DOM childElementCount Property </title> </head> <body> <h1>GeeksforGeeks</h1> <h2> DOM childElementCount Property </h2> <p>Searching Algorithms</p> <ul id="parent"> <li>Merge sort</li> <li>Quick sort</li> </ul> <button onclick="geek()">Click Here!</button> <p id="p"></p> <script> function geek() { var doc = document.getElementById("parent").childElementCount; document.getElementById("p").innerHTML = "No of entries: " + doc; } </script> </body> </html> |
Output:
Before clicking the button:

After clicking the button:

Supported Browsers: The browser supported by DOM childElementCount property are listed below:
- Google Chrome 2.0
- Internet Explorer 9.0
- Firefox 3.5
- Opera 10.0
- Safari 4.0
Recommended Posts:
- HTML | DOM name Property
- HTML | DOM value Property
- HTML | DOM li value Property
- HTML | DOM specified Property
- HTML | DOM Bdo dir Property
- HTML | DOM dir Property
- HTML | DOM Map name Property
- HTML | DOM id Property
- HTML | DOM URL Property
- HTML | DOM HR color Property
- HTML | DOM nextElementSibling Property
- HTML | DOM previousSibling Property
- HTML | DOM domain Property
- HTML | DOM isContentEditable Property
- HTML | DOM Meter min Property
- HTML | DOM implementation Property
- HTML | DOM offsetLeft Property
- HTML | DOM referrer Property
- HTML | DOM HR noshade Property
- HTML | DOM Progress max Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


