Curriculum / Intermediate / Lesson 18

DOM: Selecting Elements

querySelector, getElementById — getting elements from the page.

18 of 30
intermediate 📖 5 min read 🎯 3 questions

What is the DOM?

The Document Object Model (DOM) is a representation of your HTML page that JavaScript can interact with. You can select, modify, and delete elements.

💡 Key insight The DOM is like a tree structure where each HTML element is a node. JavaScript gives you tools to navigate and manipulate this tree.

Selecting Elements

Common Mistakes

Quick Quiz

1. Which method selects elements by ID?

2. Which method returns all matching elements?

3. What does document.querySelector('.class') return?

Summary

Back to curriculum