How to add or remove a class on hover using jQuery

To add or remove a class on hover using jQuery you can use the snippet below.

Adding a Class

See this JSFiddle for adding a CSS-Class.

$('#test1').hover(function(){  $(this).addClass('hoverClass');});

Removing a Class

See this JSFiddle for removing a CSS-Class.

$('#test1').hover(function(){  $(this).removeClass('hoverClass');});

Please Share us:
Please rate this snippet

15 thoughts on “How to add or remove a class on hover using jQuery

Leave a Reply