The document Object
- The
document
object is your door into accessing DOM objects - Has a number of useful properties and methods for accessing elements
document.getElementById()
- Gets an element with a particular id attributedocument.getElementsByClassName()
- Gets all elements with a particular class attributedocument.querySelector()
- Gets the first element with a CSS selector
// <h1 id="my-heading">This is a heading</h1>
const heading = document.getElementById("my-heading");
heading.textContent = "New heading text";
20 / 24