views:

59

answers:

1

I am trying to show a div when the cursor hovers over and image and hide the div when It is not hovered over the image how is this done?? So far I have a basic show:

  <script type="text/javascript">

  $(document).ready(function(){

  $(".plans").hover(function()
  {
    $("#planssubnav").show("slow");
  }

);

});

  </script>
+2  A: 

Try this:

 $(document).ready(function(){
  $(".plans").hover(function() {
    $("#planssubnav").show("slow");
  }, function(){
    $("#planssubnav").hide("slow");
  });
 });

The hover method needs two functions (second one is optional though), first one is executed when mouse enters the wrapped set and the second one when mouse leaves it, so you were missing the second one to hide it.

Sarfraz
Technically it does not need two functions. If only one is provided, it is called on both, mouse in and out.
Felix Kling
Good tip, Felix :)
Dan Heberden
@Felix: Good pointed, updated, thanks
Sarfraz