How to Remove Multiple Classes from an Element with JavaScript?

Estimated read time 1 min read

To remove multiple classes from an element with JavaScript, you can use the classList property and call the remove() method multiple times. Here’s an example:

let el = document.getElementById("my-element");
el.classList.remove("class-1", "class-2", "class-3");

This code removes the classes "class-1", "class-2", and "class-3" from the element with id="my-element" using the classList property.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply