javascript tutorial - [Solved-5 Solutions] Add a class
- javascript - java script - javascript array
Problem:
How do we add a class to a given element?
Solution 1:
a element that already has a class:
Solution 2:
Add a space plus the name of your new class to the className property of the element. First, put an id on the element so you can easily get a reference.