English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The removeClass() method removes one or more class names from the selected elements.
If the class name is included as a parameter, only that class will be removed.
If the class name is not specified in the parameter, all classes will be removed.
Remove all classes
$.removeClass()
Remove the specified class
$.removeClass(className)
Use a function to remove a class
$.removeClass(function(index, currentClass))
Remove the class name "highlight" from all <p> elements:
$("button").click(function(){ $("p").removeClass("highlight"); });Test and see‹/›
One can remove more than one class (separated by spaces) from a set of selected elements, as shown below:
$("button").click(function(){ $("p").removeClass("highlight big"); });Test and see‹/›
If the class name is not specified in the parameter, all classes will be removed:
$("button").click(function(){ $("p").removeClass(); });Test and see‹/›
Use removeClass() to remove a class and add a new class using addClass():
$("button").click(function(){ $("p").removeClass("red").addClass("green"); });Test and see‹/›
Parameter | Description |
---|---|
className | Specify one or more (separated by spaces) class names to be removed Note:If this parameter is empty, all class names will be removed |
function(index, currentClass) | Returns a function to remove one or more class names separated by spaces
|