removeClass()
method?The removeClass()
method is used to remove one, multiple, or all the class names from the class attributes of the matched elements.
In an HTML document, elements may have a class attribute with one or more class names for that element. This class attribute is used by CSS or JavaScript to perform certain tasks on the element.
For instance, elements with the same class name in the class attribute can be used to apply the same style on them using CSS.
The removeClass()
method has three signatures:
removeClass()
: Call to the method$().removeClass()
removeClass()
: Call to the methodclassName
: One or more space-separated class names to be removed from the class attribute of each matched element.$().removeClass([className])
removeClass()
: Call to the methodfunction
: A function returning one or more space-separated class names to be removed from the class attribute of each matched element. The function receives the index position of the element in the set and the old class value as arguments.$().removeClass(function(){})
Here are some examples showing the use of removeClass()
method signatures:
Calling removeClass()
method without any argument removes all the class names from the class attribute of the selected element.
Calling removeClass([classname])
method with space separated list as an argument removes all specified class names from the class attribute of the selected element.
Calling removeClass(function)
method with a function as an argument expects a space separated list of class names that are removed from the class attribute of the selected elements.