Lesson 9 of 20
DOM & Events
Respond to clicks and update page content.
Introduction
The DOM is the browser's object representation of the page.
Event listeners let JavaScript respond to interactions such as clicks, input and form submission.
Key insight
Respond to clicks and update page content.
Example
const button = document.querySelector("button");
button?.addEventListener("click", () => {
console.log("Clicked");
});This example shows the core dom & events idea in a small, runnable program.
Real-world example
DOM & Events appears in everyday application code, scripts and APIs.
Test yourself
2-question check
1
What is the main idea in DOM & Events?
2
Where can dom & events be useful?
Ready to check your understanding?
Answer every question, then submit your quiz.
Try it yourself
JavaScript compiler
Runs in your browser. Nothing is sent to a server.
Output appears here
Practice challenge
Attach a click handler that changes a heading's text.