How to remove a class from body with JavaScript?

Sometimes, we want to remove a class from body with JavaScript.

In this article, we’ll look at how to remove a class from body with JavaScript.

How to remove a class from body with JavaScript?

To remove a class from body with JavaScript, we can use the classList.remove method.

For instance, we write:

document.querySelector('body').classList.remove('no-javascript');

to remove the no-javascript class from the HTML body element.

We select the body element with querySelector.

Then we call classList.remove with the class names we want to remove.

Conclusion

To remove a class from body with JavaScript, we can use the classList.remove method.