![]() |
VOOZH | about |
The toggleClass() method is an inbuilt method in jQuery that is used to toggle or change the class attached to the selected element.
Syntax:
$(selector).toggleClass(class, function, switch)
Parameters:
This method accepts three parameters as mentioned above and described below:
Return Value: This method returns the selected element with the specified changes made by the toggleClass() method.
The below examples illustrate the toggleClass() method in jQuery:
Example 1:
Output:
Example 2:
Output: