Add or remove class(es) from the matched elements, depending on either the class's presence or the value of the switch argument. Also accepts a function.
function
Optional
Name of the class. Can also be a function.
If specified the state of the class.
The instance itself.
$('.apple.green').toggleClass('fruit green red').prop('outerHTML');//=> <li class="apple fruit red">Apple</li>$('.apple.green').toggleClass('fruit green red', true).prop('outerHTML');//=> <li class="apple green fruit red">Apple</li> Copy
$('.apple.green').toggleClass('fruit green red').prop('outerHTML');//=> <li class="apple fruit red">Apple</li>$('.apple.green').toggleClass('fruit green red', true).prop('outerHTML');//=> <li class="apple green fruit red">Apple</li>
https://api.jquery.com/toggleClass/
Add or remove class(es) from the matched elements, depending on either the class's presence or the value of the switch argument. Also accepts a
function.