jQuery Attribute Operation - removeClass() Method

Example

Remove the "intro" class from all <p>:

$("button").click(function(){
  $("p:first").removeClass("intro");
});

Try it yourself

Definition and Usage

The removeClass() method removes one or more classes from the selected element.

Note:If no parameters are specified, this method will remove all classes from the selected element.

Syntax

$(selector).removeClass(class)
Parameters Description
class

Optional. Specifies the name of the class to be removed.

To remove multiple classes, use spaces to separate the class names.

If this parameter is not set, all classes will be removed.

Use the function to remove the class

Use the function to remove the class from the selected element.

$(selector).removeClass(function(index, oldclass))

Try it yourself

Parameters Description
function(index, oldclass)

Required. Removes the specified class by running the function.

  • index - Optional. Accepts the index position of the selector.
  • html - Optional. Accepts the old class value of the selector.

More examples

Change the class of an element
How to use addClass() and removeClass() to remove a class and add a new one.