I have a menu consisting of a single image (e.g. sprites). To display the hover image, I simply move the background image down. I would like this effect to be controlled by jQuery and animated.
This is an example of a menu item.
<ul>
<li id="home"><a href="#"></a></li>
</ul>
This is what I play with. I am very new to jQuery and I have problems with the correct selector.
$(document).ready(function(){
$('#home a');
.css( {backgroundPosition: "0 0"} )
.mouseover(function(){
$(this).stop().animate({backgroundPosition:"(0 -54px)"}, {duration:500})
})
.mouseout(function(){
$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500})
})
});
Could you please indicate what I am doing wrong? I know that the selector is probably wrong, but it's hard for me to figure out how to manipulate the anchor.
source
share