How about element.classList.toggle() see https://developer.mozilla.org/en-US/docs/Web/API/Element.classList