JavaScript DOM childNodes.length also returning number of text nodes
You could use Element.children
, but IE (up to 8) seems to consider comment nodes too.
Not directly. Text nodes (including comments and so on) are child nodes.
Your best bet is to iterate over the childNodes array and count up only those nodes with nodeType == Node.ELEMENT_NODE
. (And write a function to do so.)