jQuery .removeClass(): Remove Specific or All Classes
.removeClass() removes specified class names from matched elements. With no argument, it removes every class, so name the classes explicitly when clearing only a particular state.
Syntax and behavior
$(".item").removeClass("active");
$(".item").removeClass("marked active");
$(".item").removeClass();
Pass multiple names in a space-separated string or an array. Other classes remain, and removing a class that is absent does not cause an error. After removal, the remaining classes and other style rules determine the appearance; the element does not necessarily return to the browser’s default styling. The returned value is the original jQuery object.
The official jQuery .removeClass() documentation describes additional call signatures and argument types.
Complete runnable example
Save the following code as a UTF-8 example.html file and open it in a browser. It loads the full jQuery 4.0.0 build from an external URL, so an internet connection is required. The $(function () { ... }) callback waits for the document to be ready before running the example.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery removeClass example</title>
<style>
body { margin: 24px; font-family: sans-serif; line-height: 1.6; }
.marked { background: #fff0b3; border: 2px solid #835b00; }
.active { color: #a00000; font-weight: bold; }
button, input, select { font: inherit; }
#output { white-space: pre-wrap; overflow-wrap: anywhere; }
</style>
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
</head>
<body>
<p id="a" class="item base marked active">Highlighted item</p>
<p id="b" class="item base marked active">Second item</p>
<p id="output" aria-live="polite"></p>
<script>
$(function () {
$("#a").removeClass("active");
$("#b").removeClass("marked active");
$("#output").text("a: " + $("#a").attr("class") + " / b: " + $("#b").attr("class"));
});
</script>
</body>
</html>
Expected result
Paragraph a loses its red-text class but retains the background and border. Paragraph b loses both highlight classes. The output is a: item base marked / b: item base.
Important details and troubleshooting
- Calling .removeClass() without an argument can also remove classes used for layout or identifying event targets. Remove only the state names you intend to clear.
- The argument is a class name, not a selector. Do not include a leading dot.
- Removing classes does not clear inline style attributes. Clear properties set with .css() separately, or manage the state through CSS classes.
Compare the behavior with .addClass() and CSS classes, .toggleClass() and explicit state.








