tags:

views:

18

answers:

1

I am trying to do a disjointed jquery hover. When the user hovers the cursor over a menu item, an image in the sidebar should swap to a secondary image. However, I have been unable to get it to work.

Here is the jquery:

$('#main-menu li a').hover(function() {
    $("#vette").attr("src","images/vette2.png");
});

Here is the HTML

<div id="main-menu">
<ul>
<li><a href="#">Link1</a></li>
<li><a href="#">Link2</a></li>
<li><a href="#">Link3</a></li>
</ul>
</div>


<div>
<img src="images/vette1.png" id="vette">
</div>
+1  A: 

It should work, but if you want to restore the original if you leave the item, you need to add a second function:

$('#main-menu li a').hover(
 function() {$("#vette").attr("src","images/vette2.png");},
 function() {$("#vette").attr("src","images/vette1.png");}
);
Dr.Molle
I'm a retard :P I was missing my document ready. That was it. Thanks!
Batfan