remove method of the classList object
The remove method of the
classList
object removes a given CSS class
of an element.
Syntax
element.classList.remove(class);
Example
We remove the class ggg:
<p id="elem" class="www ggg zzz"></p>
let elem = document.querySelector('#elem');
elem.classList.remove('ggg');
The code execution result:
<p id="elem" class="www zzz"></p>
See also
-
the
classList.addmethod
that adds a given class -
the
classList.containsmethod
that checks a given class -
the
classList.togglemethod
which toggles a given class