jQuery: hover selector

hankknight used Ask the Experts™
Using jQuery, How can I select a hovered link?

This does NOT work:
$("#menuSide a:hover em").css("background", 'green');

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007
why would you want to do this?!!!

you could do this in pure CSS as:

#menuSide a:hover em {background:green}

:hover is not supported by jQuery it looks like: http://api.jquery.com/category/selectors/

and anyway, a hovered link will only be hovered as long as the mouse is over it. Your script would need to know when that happened or continuously keep checking for the hover.

if you still want to do something to the link on hover you can do it with '.hover()' like this:

$('#something a').hover(function(){
                          $(this).css({'something': 'thomesing'});
                          $(this).css({'something': 'previous'});

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial