{{ APIRef("DOM") }}
Node.children
is a read-only property that returns a live {{domxref("HTMLCollection")}} of the child elements of Node
.
Syntax
var elList = elementNodeReference.children;
elList
is a {{ domxref("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
.
Example
// 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
}
Specification
Specification |
Status |
Comment |
{{SpecName('DOM WHATWG', '#dom-parentnode-children', 'ParentNode.children')}} |
{{Spec2('DOM WHATWG')}} |
Initial definition. |
Browser compatibility
{{ CompatibilityTable() }}
Feature |
Chrome |
Firefox (Gecko) |
Internet Explorer |
Edge |
Opera |
Safari |
Basic support (on {{domxref("Element")}}) |
1.0 |
{{CompatGeckoDesktop("1.9.1")}} |
9.0 [1] |
|
10.0 |
4.0 |
Support on {{domxref("Document")}} and {{domxref("DocumentFragment")}} {{experimental_inline}} |
29.0 |
{{CompatGeckoDesktop("25.0")}} |
{{CompatNo}} |
|
16.0 |
{{CompatNo}} |
Support on {{domxref("SVGElement")}} |
{{CompatVersionUnknown}} |
{{CompatVersionUnknown}} |
{{CompatNo}} |
|
{{CompatUnknown}} |
{{CompatNo}} |
Feature |
Android |
Firefox Mobile (Gecko) |
IE Mobile |
Opera Mobile |
Safari Mobile |
Basic support (on {{domxref("Element")}}) |
{{ CompatVersionUnknown() }} |
{{CompatGeckoMobile("1.9.1")}} |
{{ CompatVersionUnknown() }} |
{{ CompatVersionUnknown() }} |
{{ CompatVersionUnknown() }} |
Support on {{domxref("Document")}} and {{domxref("DocumentFragment")}} {{experimental_inline}} |
{{CompatVersionUnknown}} |
{{CompatGeckoMobile("25.0")}} |
{{CompatNo}} |
16.0 |
{{CompatNo}} |
[1] Internet Explorer 6, 7 and 8 supported it, but erroneously includes {{domxref("Comment")}} nodes.
See also