Remove class from HTML element
JavaScript, Browser · Dec 30, 2020

Removes a class from an HTML element.
- Use
Element.classList
andDOMTokenList.remove()
to remove the specified class from the element.
const removeClass = (el, className) => el.classList.remove(className);
removeClass(document.querySelector('p.special'), 'special');
// The paragraph will not have the 'special' class anymore
Written by Angelos Chalaris
I'm Angelos Chalaris, a JavaScript software engineer, based in Athens, Greece. The best snippets from my coding adventures are published here to help others learn to code.
If you want to keep in touch, follow me on GitHub.