ParentNode.children

Node.children is a read-only property that returns a live HTMLCollection of the child elements of Node.

SyntaxEdit

var elList = elementNodeReference.children; 

elList is a HTMLCollection, which is an ordered collection of DOM elements that are children of elementNodeReference. If there are no element children, then elList contains no elements and has a length of 0.

ExampleEdit

// pEl is a reference to a <p> element
var elementChildren = pEl.children;
for (var i = 0; i < elementChildren.length; i++) {
    console.log(elementChildren[i].tagName);
    // NOTE: elementChildren is a live list, adding or removing children from pEl
    // will change the members of elementChildren immediately
}

SpecificationEdit

Specification Status Comment
DOM
The definition of 'ParentNode.children' in that specification.
Living Standard Initial definition.

Browser compatibilityEdit

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (on Element) 1.0 3.5 (1.9.1) 9.0 [1] 10.0 4.0
Support on Document and DocumentFragment 29.0 25.0 (25.0) Not supported 16.0 Not supported
Support on SVGElement (Yes) (Yes) Not supported ? Not supported

[1] Internet Explorer 6, 7 and 8 supported it, but erroneously includes Comment nodes.

See alsoEdit

Document Tags and Contributors

 Last updated by: Robg1,