How to remove a class in JavaScript?

To remove a class in JavaScript, do this: element.classList.remove('class').

For example, if this is your element with a few classes:

<div id="my-div" class="first-class second-class third-class"></div>

Then you can remove, say, second-class with this JavaScript:

document.getElementById('my-div').classList.remove('second-class')