Home > DeveloperSection > Forums > Jquery: Append a Class on hover of a div and remove when not hover
Samuel Fernandes
Samuel Fernandes

Total Post:156

Points:1096
Posted on    May-11-2013 3:12 AM

 JQuery JQuery 
Ratings:


 1 Reply(s)
 1458  View(s)
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!



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-11-2013 9:56 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick