The DOM (Document Object Model) allows JavaScript to interact with HTML elements dynamically.
Use document.getElementById
or document.querySelector
to select elements:
let element = document.getElementById("myElement");
let anotherElement = document.querySelector(".myClass");
Change content or styles of an element:
element.textContent = "Hello!";
element.style.color = "blue";
Create a button in HTML. When clicked, change the text of an element on the page.
Answers: The structure of a webpage; getElementById
; use textContent
.