warvariuc warvariuc - 1 year ago 251
Javascript Question

Clear element.classList

is of
DOMTokenList
type.

Is there a method to clear this list?

Answer Source

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 = "";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download