Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add and remove a class on click event

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 223
    Comment on it

    hii,

    Today i am sharing a blog on How to add and remove a class on click event in javascript.

    First of all you need to either download few plugins or just copy and paste the below link inside head tag.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
    </script>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    

    Note:The above mentioned link will be written inside head tag

    Code for adding and removing class on click event:

    <script type="text/javascript">
    $(document).ready(function(){
       $(".className").click(function(){
       $(this).addClass("active");
       $(this).removeClass("inactive");
        });
    });
    
    </script>
    

    Note:The above mentioned code can be either added in head tag or in body tag.

 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: