document.querySelectorAll() Query all matches
Last updated: 2026-09-09
document.querySelectorAll() Query all matches
querySelectorAll returns a NodeList of all matching elements.
| Category | DOM |
|---|---|
| ES version | DOM |
📝 Syntax
document.querySelectorAll('.items');
⚙️ Parameters
| selector | A CSS selector. |
|---|
Returns:A NodeList (iterable with forEach).
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
(prints each element's text)
💡 Tip NodeList has forEach but not map/filter — spread to a real array.
ℹ️ info Static NodeList — does not auto-update when DOM changes.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| document.querySelectorAll() | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Items
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
QNodeList vs Array?
ANodeList has forEach only; spread to Array for map/filter.
QStatic or dynamic?
AStatic — does not auto-update.
QHow to convert to Array?
A[...nodeList] or Array.from(nodeList).