element.childNodes and element.childNodes.length : includes child elements, text nodes (including node nodes between elements) and comments (plus potentially CDATASections, ProcessingInstructions, DocumentTypes and EntityReferences, depending on the document and parser). Defined by the DOM Level 1 Core standard and has been available in every browser for many years.
element.children and element.childElementCount : contains only the nodes of the elements, so in some cases they are easier to handle. childElementCount defined by the Element Traversal API standard and is available in the latest versions of Mozilla, Opera, and WebKit. children not defined by any standard, but is available in IE and updated versions of Mozilla, Opera, WebKit, and IE.
bobince
source share