Selecting Elements
1 min read
The DOM
The DOM (Document Object Model) is how JavaScript sees your HTML page.
// select one element
const title = document.querySelector("h1");
// change its text
title.textContent = "Updated!";
Responding to clicks
const btn = document.querySelector("#myButton");
btn.addEventListener("click", () => {
alert("Clicked!");
});