DOM element childElementCount


Retrieves the number of immediate child nodes of the current element or a zero if the element does not contain any child nodes. childElementCount does not return all child nodes, only child nodes that are nodeType =1, or element nodes.
This DIV with id="testRoot" starts with an em and HAS EMPTY TEXT NODES.

and then comes a paragraph with id="testPar" which has a strong tag nested in it.

And after a comment comes this div.

And in this nested paragraph I remind you that there are empty text nodes between the elements.

Source Code

            if (document.getElementById('testRoot').childElementCount)
                alert('childElementCount is supported, result is ' + document.getElementById('testRoot').childElementCount);
                alert('childElementCount is not supported');