This site runs best with JavaScript enabled.

Remove multiple classes

Kevin Beck

July 31, 2019


You can easily add or remove multiple classes using the ES6 spread syntax in JavaScript

// add or remove multiple classes using spread syntax
const yourClasses = ["foo", "bar"];
yourElement.classList.add(...yourClasses);
yourElement.classList.remove(...yourClasses);