Consider following HTML snippet:

<span id="myDog" class="animal dog">My dog</span>
How many classes will have #myDog element after executing the folloding code:

$("#myDog").addClass("barker").removeClass("animal").toggleClass("lazy"); ?
<span id="myDog" class="animal dog"> // 2 classes animal and dog addClass("barker") // add class "barker" - 3 classes removeClass("animal") // remove class "animal" - 2 classes toggleClass("lazy") // add class "lazy" - 3 classes In case #myDog element already has class "lazy", the toggleClass() then method would remove it.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback