Skip to content Skip to sidebar Skip to footer

Add And Remove Classes In Order With Jquery

Im trying to say that, if my div doesnt have the class active add it. And if it does have the class active, remove it. Ive the following, only my code adds the class, then continu

Solution 1:

Use toggleClass method:

$(".work-showcase").click(function() {
    $(this).toggleClass("active");
})

Solution 2:

$("#YourID").removeClass('ClassName'); $("#YourID").addClass('ClassName');

Post a Comment for "Add And Remove Classes In Order With Jquery"