warvariuc warvariuc - 10 months ago 186
Javascript Question

Clear element.classList

is of

Is there a method to clear this list?


I'm not aware of a "method" in the sense of a "function" associated with classList. It has .add() and .remove() methods to add or remove individual classes, but you can clear the list in the sense of removing all classes from the element like this:

element.className = "";