DOM Node.childNodes Property
The childNodes property returns a live list of all the child nodes of a node, including text and comments.
Description
The read-only childNodes property returns a live NodeList of the node's child nodes. Unlike children, it includes text nodes (even the white space between tags) and comments. Use children when you only want elements.
Because the list is live, its length changes as children are added or removed, which can catch you out when looping and modifying at the same time. It supports forEach() and for...of; for array methods, copy it with Array.from().
To check whether a node has any children at all, hasChildNodes() is a shortcut. The order of the list always matches the order of the nodes in the document.
Syntax
node.childNodesValue
A live NodeList of all child nodes, including text and comment nodes.
Example
Browser Support
The following information will show you the current browser support for the Node.childNodes property. Hover over a browser icon to see the version that first introduced support for this property.
Desktop





Tablets & Mobile





