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

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

element.classList.add('new-class-name');
copy
Full Javascript cheatsheet
Sitemap Git repository