Web APIs

Element.children

Try the free JavaScript compiler

Expose a live collection of direct child elements, excluding text and comment nodes. Example console output: 1 2.

Formal Syntax & Structure

javascript syntaxjavascript
element.children

Return Value

HTMLCollection

Direct child elements.

Working Example

Example Snippetjavascript
const root=document.createElement("div"); root.append("text",document.createElement("span")); console.log(root.children.length,root.childNodes.length);
JavaScript Reference