A little dab'll do ya
Code Snippets
Adding/Removing Class on Hover
$('#elm').hover(
function(){ $(this).addClass('hover') },
function(){ $(this).removeClass('hover') }
)This will work in any browser on any element, to support styling changes on hover.
isn’t it easier to use “toggleClass()” ????
There are many different ways to accomplish the same goal, its however invauable to know to many!
I realize this is about a year old, but the reason the add/remove class is more appropriate sometimes is if you have more than one trigger on a page for the same element. It’s simply more dummy-proof!
Simple but great code snippet.
Thnx…
Thanks for the post, this works well when you want to be cross browser compatible and remove any :hover class’ from your CSS
You saved my life. thx