user342391
user342391

Reputation: 7827

How can I show a div with Jquery hover and then hide?

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>

Upvotes: 0

Views: 1112

Answers (1)

Sarfraz
Sarfraz

Reputation: 382696

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.

Upvotes: 2

Related Questions