Jquery: Append a Class on hover of a div and remove when not hover

Total Post:159

Points:1117

JQuery 
 2229  View(s)
Ratings:
Rate this:
Hi Expert!

I want to append a class to a div on hover of that div and remove that class when its not on hover. And when I hover on another div, again this class should be 

appended and removed when its not on hover. Someone say me how to do it in jquery......

Thanks in advance!

  1. Re: Jquery: Append a Class on hover of a div and remove when not hover

    Hi Samuel!

    replace addClass and removeClass functions in jquery as following 

    $(document).ready(function() {     
        $('#secID, #thID').hover(function(){     
            $('#oneID').addClass('red');    
        },     
        function(){    
            $('#oneID').removeClass('red');     
        });
    });  

    I hope it is useful to you

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.