JavaScript · DOM and events
classList
Manages classes without touching the class attribute string. Supports add, remove, toggle and contains.
Syntax
el.classList.add("active")Example
Try it
More in this group
Learn this in the course
Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.