warvariuc warvariuc - 3 months ago 44
Javascript Question

Clear element.classList

is of
DOMTokenList
type.

Is there a method to clear this list?

Answer

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 = "";