Stage 1 · Lesson 5 of 8
The DOM and events
The is the live tree of objects the browser builds from your . changes the page by changing that tree. Learn to find elements with querySelector and to create new ones.
Set text with textContent. Never use innerHTML with anything a user typed, because it lets attackers run their own scripts (). Listen for clicks and key presses with addEventListener.
Events bubble: they travel up from the clicked element through its parents. That allows event delegation, where one listener on a list handles clicks on every item, even ones added later. In a form's submit handler, call event.preventDefault() to stop the full page reload.
Doing this by hand once makes feel like a relief rather than magic in the next stage.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking JavaScript Fundamentals
Design Gurus · Beginner · $50
Guided course on the language core if you want structure and quizzes
- CourseFreeThe Odin Project
The Odin Project · Beginner
Free Foundations course: HTML, CSS and JavaScript built in your own editor
Practise
Keep handy
Also worth your time
The request path from browser to server that the rest of this roadmap builds on