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

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.

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