.toggleClass() | jquery set class
Description:Addorremoveoneormoreclassesfromeachelementinthesetofmatchedelements,dependingoneithertheclassspresenceorthevalueofthestateargument.Thismethodtakesoneormoreclassesasitsparameter.Inthefirstversion,ifanelementinthematchedsetofelementsalreadyhastheclass,thenitisremoved;ifanelementdoesnothavetheclass,thenitisadded.Forexample,wecanapply.toggleClass()toasimple
Description: Add or remove one or more classes from each element in the set of matched elements, depending on either the classs presence or the value of the state argument.
This method takes one or more classes as its parameter. In the first version, if an element in the matched set of elements already has the class, then it is removed; if an element does not have the class, then it is added. For example, we can apply .toggleClass() to a simple <div>:
1
<div class="tumble">Some text.</div>
The first time we apply $( "div.tumble" ).toggleClass( "bounce" ), we get the following:
1
<div class="tumble bounce">Some text.</div>
The second time we apply $( "div.tumble" ).toggleClass( "bounce" ), the <div> class is returned to the single tumble value:
...