Lesson 12 of 18

📄 DOM Manipulation

🎯 Grades 9–12 ⏱ ~40 minutes 🟡 Intermediate

What You'll Learn

  • What the DOM is and how JavaScript sees your HTML as a tree of objects
  • Selecting elements: getElementById, querySelector, querySelectorAll
  • Changing text, HTML, styles, classes, and creating/removing elements
Quick Check

1. What does the DOM represent?

AThe CSS styles applied to the page
BThe browser's in-memory tree of HTML elements
CThe JavaScript engine

2. Which selects ALL elements matching a CSS selector?

Adocument.querySelector()
Bdocument.querySelectorAll()
Cdocument.getElementById()

3. What is the difference between textContent and innerHTML?

AThey are identical
BtextContent sets plain text; innerHTML parses and renders HTML tags
CinnerHTML sets plain text; textContent parses HTML

4. How do you toggle a CSS class on an element?

Ael.style.toggle("active")
Bel.classList.toggle("active")
Cel.class = "active"