Skip to content

Day 1: What is the DOM & Element Selection

Understand the DOM tree representation and select elements using modern selectors.

// Single elements
const title = document.getElementById('main-title');
const firstButton = document.querySelector('.btn-primary');
// Multiple elements (NodeList)
const allCards = document.querySelectorAll('.card');
allCards.forEach(card => card.classList.add('shadow'));
  1. Create an HTML page with multiple paragraphs and buttons.
  2. Select them using querySelector and querySelectorAll and log them to console.