Learn HTML DOM
Accessing DOM Elements
3.1
Lesson

Selecting DOM Elements Using ID

In order to manipulate any DOM element, we need to be able to select them first.

This is where selectors come in.

getElementById will select the HTML element which matches the provided id value.

If you’d look at the code example, you can see that the text Win! is now larger than the other text. And if you look at the console, you’ll see that currentInspiration refers to the p element. The browser views it as a DOM object with properties.