Web APIs
Element.querySelectorAll()
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
| Name | Type | Description |
|---|---|---|
| selectors | string | CSS 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);