Web Development / JavaScript
Lesson 20 of 30
The DOM
The DOM is the page as JavaScript objects. Find elements with querySelector and change their text or classes.
Key points
- document.querySelector('.card')
- el.textContent = 'Hi' (safe)
- el.classList.toggle('active')
const title = document.querySelector("h1");
title.textContent = "Welcome back!";Quiz · +10 XP
Which is the safe way to put user text into the page?
Log in to save progress and earn XP.