Add/Remove class on hover by JS.

Now a day’s almost all browsers support :hover property by CSS. But sometimes we want JS to add and remove class or any other css properties on hover so that we can do easily.



function(){ $(this).addClass('class-1')},

function(){ $(this).removeClass(' class-2')}



Note: Don’t forget to add jquery library before using jQuery (This is common mistake that I also did while coding :P )



Written by Ranjeet Jha

Ranjeet Jha

Hey there! My name is Ranjeet. I’m a Web Designer & Front-end Developer. I design, code, build & promote all things HTML5, CSS3, JavaScript & jQuery. In this blog you will find solutions of day to day problems faced by you.. Enjoy Coding..

Leave a Reply

Your email address will not be published. Required fields are marked *