This post will discuss how to remove a specific CSS class from an HTML element using JavaScript and jQuery.

1. Using jQuery

With jQuery, you can use the .removeClass() method for removing the specific class from an element. This is demonstrated below, where removeClass() is used to remove the color class from the div container.

JS


CSS


HTML



Edit in JSFiddle

 
However, this won’t remove any inline styles applied to the element using the style attribute. You can also specify the list of CSS classes to be removed from the element, as shown below. Spaces should separate the multiple classes.

JS


CSS


HTML



Edit in JSFiddle

2. Using JavaScript

In plain JavaScript, you can use the Element.classList.remove() method to remove the specific class from an element. Like jQuery’s removeClass() method, this won’t remove any inline styles applied to the element using the style attribute.

JS


CSS


HTML



Edit in JSFiddle

That’s all about removing a specific CSS class from an HTML element using JavaScript and Query.