Ram

Lesson 5 of 6

DOM & Events

Respond to clicks and update page content.

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.

Example

const button = document.querySelector("button");
button?.addEventListener("click", () => {
  console.log("Clicked");
});

Practice challenge

Attach a click handler that changes a heading's text.

Previous
Next