1. Home
  2. Javascript
  3. Class list toggle class
#javascript#class#list

This method lets you toggle a class in the class list property. It will also return True if the class has been added and False when the class was toggled off. Use only the class name without the dot notation. 'toggle' method belongs to the 'classList' property.

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