Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Add/Remove multiple classes in Jquery

    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 533
    Comment on it

    If you want to remove mutiple classes on click of a button:
    HTML:

    <div class="container">
    <span class="class1 class2 class3"></span>
    <button id="clear" type="button"></button>
    </div>
    

    JS:

    $("#clear").click(function(){
        $("span").removeClass("class2 class3")
    });
    

    To add mutiple classes:

       $("#clear").click(function(){
            $("span").addClass("class2 class3")
        });
    

    This is how you can add/remove multiple classes.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: