Learn HTML DOM
Manipulating DOM Elements
4.7
Lesson

Adding Class to an Element

We can add class values to an element using the classList property.

The classList property returns a list of all the class attributes of the element. We then add class names separated by commas to this list using the add method on the classList property.