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

Total Post:159

Points:1117
JQuery 
 2135  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. Post:604

    Points:4228
    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