jqueryHow do I remove a class using jQuery?
Removing a class from an element using jQuery is simple. To do so, you can use the removeClass()
method. This method takes one argument, the class that you want to remove. Here is an example:
$("p").removeClass("intro");
This code will remove the class "intro" from all <p>
elements on the page.
The removeClass()
method is part of the jQuery API and is used to manipulate the class attribute of an element. It takes one argument, the class name that you want to remove. If you want to remove multiple classes, you can pass a space-separated list of classes as the argument.
Code explanation
-
$("p")
- This is a jQuery selector that selects all<p>
elements on the page. -
removeClass()
- This is the method used to remove a class from an element. -
"intro"
- This is the class name that is being removed from the<p>
elements.
Helpful links
- jQuery removeClass() - jQuery API documentation on the
removeClass()
method.
More of Jquery
- How can I get the y position of an element using jQuery?
- How can I use JQuery with Yii2?
- How do I use the jQuery masked input plugin?
- How do I uncheck a checkbox using jQuery?
- How can I convert jQuery code to vanilla JavaScript?
- How can I convert XML data to JSON using jQuery?
- How can I use jQuery to control the visibility of an element?
- How do I use the jQuery UI Datepicker?
- How do I use jQuery to trigger an event?
- How do I use jQuery to toggle an element?
See more codes...