jQuery removeClass() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
CSS

Definition

.removeClass() removes one or more CSS class names from each matched element (since jQuery 1.0). Named classes are stripped; others stay. With no arguments, every class is cleared.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("p").removeClass("blue")
$("p").removeClass("blue under")          // multiple (space)
$("p").removeClass(["blue", "under"])     // array (3.3+)
$("p").eq(1).removeClass()                // remove ALL classes

// Switch state:
$("p").removeClass("old").addClass("new")
CallWhat it does
removeClass()Learn jQuery .removeClass(): strip one, some, or all CSS class names from matched elements, string array and callback forms, examples, pitfalls, and FAQs.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Select the element(s) with a jQuery selector.
Step 2Call .removeClass("name") — or a space list / array / callback.
Step 3Omit arguments only when you truly want every class gone.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Remove One Class

Strip blue; leave other classes on the element.

jQuery
// <p class="blue under">Hello</p>
$("p").removeClass("blue");
console.log($("p").attr("class")); // "under"
Try It Yourself

How It Works

  1. Start. The paragraph has blue and under.
  2. Strip. removeClass("blue") targets only that name.
  3. Keep. under remains on the class attribute.

Example 2 — Multiple Classes (String or Array)

Remove several names in one call.

jQuery
// <p class="blue under highlight">Hello</p>
$("p").removeClass("blue under");
// same as: $("p").removeClass(["blue", "under"]);
console.log($("p").attr("class")); // "highlight"
Try It Yourself

How It Works

  1. List. Space-separated names (or an array since 3.3).
  2. Both gone. blue and under are removed.
  3. Remainder. highlight was not listed, so it stays.

Example 3 — Remove All Classes

Call with no arguments to clear the entire class attribute.

jQuery
// <p class="blue highlight under">and</p>
$("p").eq(0).removeClass();
console.log($("p").eq(0).attr("class")); // "" (or undefined)
Try It Yourself

How It Works

  1. No args. Means “strip everything.”
  2. Result. The element no longer has stylesheet class hooks.
  3. Scope. Only matched elements are cleared — others are untouched.

Frequently Asked Questions

.removeClass() strips one or more CSS class names from each matched element. Other classes stay. With no arguments, it removes every class from each match.
.removeClass() with no args clears the entire class attribute on every matched element. Use sparingly. To replace all classes with one new name, prefer .attr('class', 'newClass').
Yes. Pass a space-separated string — removeClass('blue under') — or since jQuery 3.3 an array — removeClass(['blue', 'under']).
Since jQuery 1.4 you can pass function(index, className). jQuery calls it once per element and removes the returned class name(s). Since 3.3 the callback may return an array.
.removeClass() always strips. .addClass() always appends. .toggleClass() flips presence. Chain removeClass().addClass() to switch exclusive states.
Yes, since jQuery 1.12/2.2 it updates the class attribute and supports SVG and XML elements.

Next: toggleClass() Method — Toggle CSS Classes

Learn how to flip CSS classes on and off without a separate hasClass check.

toggleClass() Method — Toggle CSS Classes tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful