Documentation

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

Sections

for...of Loop

Loops through each item in an array or NodeList.

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

for (const button of buttons) {
  button.classList.add('styled');
}

Perfect for looping through querySelectorAll results.