How to add or remove multiple classes in jQuery?
You can add or remove multiple classes from div/span/any tag in jQuery using the below code snippet,
Example:
<div id="mydiv">Test div</div>
$("#mydiv").addClass('class1 class2 class3');
Result:
<div id="mydiv" class="class1 class2 class3">Test div</div>
$("#mydiv").removeClass('class1 class2 class3');
Result:
<div id="mydiv">Test div</div>
Leave a comment