This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.



Returns the number of direct children of this node that are elements. Read-only.

Property of dom/Elementdom/Element


Note: This property is read-only.

var result = element.childElementCount;


This example shows how to use childElementCount to get the number of immediate children of a div tag. Descendent children of the the div tag “divWithChildren” are ignored.

<!DOCTYPE html>
        <title>childElementCount example</title>
        function GetCount () {
            var testArea = document.getElementById ("testArea");
            var childCount = 0;
                childCount = testArea.childElementCount;
            alert ("The number of child elements is " + childCount);
    <div id="testArea" >
    <p>This is the test area, which contains several children.</p>
        <div id="divWithChildren">
            <div>a descendant child of a div</div>
            <div>also a descendent child of a div</div>
        <p>A paragraph tag to consider.</p>
        <input type="text" size="80" value="And a text box as well"/>
    <p><input type="button" value="Get the number child elements in our test" name="abutton"  onclick="GetCount ();" /> </p>




The childElementCount property only returns immediate children of the current node. It does not count descendent children of the immediate children.


Standards information