Favorites

DOM Node.childNodes Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Node.childNodes
DOM Node PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

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.childNodes

Value

A live NodeList of all child nodes, including text and comment nodes.

Example

<ul id="list">
  <li>One</li>
  <!-- note -->
  <li>Two</li>
</ul>
const list = document.getElementById('list');
console.log(list.childNodes.length, list.children.length);
list.childNodes.forEach(n => console.log(n.nodeName));

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.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee