Documentation

Student-friendly HTML, CSS, and JavaScript reference with examples

Sections

querySelectorAll

Finds all elements that match a CSS selector. Returns a NodeList (array-like).

const buttons = document.querySelectorAll('button');
const boxes = document.querySelectorAll('.box');

for (const box of boxes) {
  console.log(box);
}

Use a for…of loop to iterate through the results.