DOM Element.children Property
The children property returns a live collection of an element's child elements, ignoring text and comments.
Description
The read-only children property returns a live HTMLCollection of the element's child elements only, without the text and comment nodes that childNodes includes. Use childElementCount or children.length to count them.
Because the collection is live, it updates as children are added or removed, so loop backwards or copy it with Array.from() if you change the children inside the loop. It has no forEach() method, but works with for...of.
Children can also be looked up by index, children[0], or by id or name through namedItem(). childElementCount gives the number of child elements without creating the collection.
Syntax
element.childrenValue
A live HTMLCollection of the element's child elements.
Example
Browser Support
The following information will show you the current browser support for the Element.children property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





