Web APIs

Element.querySelectorAll()

Try the free JavaScript compiler

querySelectorAll returns a static NodeList. A children HTMLCollection is live. A static list retains its original membership, but its elements can still change.

Formal Syntax & Structure

javascript syntaxjavascript
element.querySelectorAll(selectors)

Parameters & Attributes

NameTypeDescription
selectorsstringCSS selector string.

Return Value

NodeList

Static list of matching elements.

Working Example

Example Snippetjavascript
const root=document.createElement("div");const list=root.querySelectorAll("p");const live=root.children;root.append(document.createElement("p"));console.log(list.length,live.length);
JavaScript Reference