jQuery toggleClass()The jQuery toggleCLass() method is used to add or remove one or more classes from the selected elements. This method toggles between adding and removing one or more class name. It checks each element for the specified class names. If the class name is already set, it removes and if the class name is missing, it adds. In this way, it creates the toggle effect. It also facilitates you to specify to only add or only remove by the use of switch parameter. Syntax: Parameters of jQuery toggleClass() method
Example of jQuery toggleClass() methodLet's take an example to demonstrate the effect of jQuery toggleClass() method. Test it NowjQuery toggleClass() example 2Test it NowjQuery toggleClass() example 3Test it NowNext TopicjQuery width() |