1. Home
  2. Javascript
  3. Class list add a class

Append a style class to the selected element. Use only the class name without the dot notation. 'add' method belongs to the 'classList' property.

#javascript#class#list
element.classList.add('new-class-name');
copy
Full Javascript cheatsheet