What’s the difference between the children and childNodes collections of a node? And childElementCount and childNodes.length?
What’s the difference between the children and childNodes collections of a node? And childElementCount
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
element.childNodesandelement.childNodes.length: includes child elements, text nodes (including whitespace 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 on every browser for many years.element.childrenandelement.childElementCount: includes only element nodes, so can be simpler to handle in some cases.childElementCountis defined by the Element Traversal API standard and is available in the latest versions of Mozilla, Opera and WebKit.childrenis not defined by any standard, but is available in IE and up-to-date versions of Mozilla, Opera, WebKit and IE.