Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery removeClass() method

jQuery removeClass() method

jQuery HTML/CSS methods jQuery HTML/CSS methods

Example

Remove the style attribute from all the

Remove the "intro" class from the element:

$

(

"

button

"

)

.

click

(

function

(

)

{

$

(

"

p

"

)

.

removeClass

(

"

intro

"

)

;

}

)

;

Try it »


Definition and Usage

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

**Note:** If no parameter is specified, this method removes all classes from the selected elements.


Syntax

$(

selector

).removeClass(

classname

,function

(index,currentclass)

)

Parameters Description
classname Optional. Specifies one or more class names to remove. To remove several classes, separate the class names with spaces.
 **注意:** 如果该参数为空,则将移除所有类名称。 |

| function*(index,currentclass)* | Optional. A function that returns one or more class names to remove.

|

More examples

Changing an element's class name
How to use addClass() and removeClass() to remove one class name and add a new one.

Removing a class using a function
Use a function to remove a class from the selected elements.

Removing several class names
How to remove several class names from the selected elements.


jQuery HTML/CSS methods jQuery HTML/CSS methods