Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override a:hover with jQuery?

Tags:

jquery

I have defined an <a> tag with css. I'm trying to stop default stylesheet :hover changes on the a tag. How do I disable the hover changes on the a tag in Jquery?

like image 244
zsharp Avatar asked Jan 13 '10 01:01

zsharp


People also ask

Is hover deprecated in jQuery?

Is hover deprecated in jQuery? Deprecated in jQuery 1.8, removed in 1.9: The name “hover” used as a shorthand for the string “mouseenter mouseleave” .

How to set hover property in jQuery?

The hover() is an inbuilt method in jQuery which is used to specify two functions to start when mouse pointer move over the selected element. Syntax: $(selector). hover(Function_in, Function_out);

How to use hover event in jQuery?

jQuery hover() MethodThe hover() method specifies two functions to run when the mouse pointer hovers over the selected elements. This method triggers both the mouseenter and mouseleave events. Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.


1 Answers

Live demo of the following solution: http://jsbin.com/umiru

--

The easiest way I can think of is to change:

a:hover { ... }

into

a.someClass:hover { ... }

And then add/remove .someClass via jQuery's methods:

$(this).addClass("someClass");    // activates css rules for :hover
$(this).removeClass("someClass"); // deactivates css rules for :hover
like image 128
Sampson Avatar answered Sep 27 '22 21:09

Sampson