To remove a class from an element, you use the remove() method of the classList property of the element.
Suppose you have a <div> element as follows:
<div class="primary visible info">Item</div>Code language: HTML, XML (xml)To remove the visible class from the div element, you use the following code:
const div = document.querySelector('div');
div.classList.remove('info');Code language: JavaScript (javascript)The remove() method also allows you to remove multiple classes at once, like this:
const div = document.querySelector('div');
div.classList.remove('info','primary');Code language: JavaScript (javascript)Was this tutorial helpful ?