views:

40

answers:

3

In the following code once the mouse out is done the mouse over again does not work ,what is the work around for this

 <!DOCTYPE html>
  <html>
  <head>
  <style>
  /* div { background:#def3ca; margin:3px; width:80px; 
  display:none; float:left; text-align:center; }*/
  </style>
  <script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;
  </head>
  <body>
  <div id="playControls" style="position:absolute; bottom:0px; left:0px; right:0px;color:blue;">
 Mouse over me
  </div>
  <script>
  $(document).ready(function() {
  $("#playControls").mouseover(function () {
  alert('here');
  $("div:eq(0)").show("fast", function () {
     /* use callee so don't have to name the function */
     $(this).next("div").show("fast", arguments.callee);
  });
  });
  $("#playControls").mouseout(function () {
  alert('here');
  $("div").hide(2000);
  });
  });

  </script>
  </body>
  </html>
+1  A: 

This line hides all divs on your page:

$("div").hide(2000);

I don't think this is what you want. It will also hide the div which handles the mouseover/mouseout.

I think you meant:

$(this).next("div").hide(2000);

This will hide only the div you wanted.

Philippe Leybaert
No i dont want this ,but i should be able to retrieve the div back,How is it to be done
Hulk
It's not very clear what the expected behavior is. Can you explain what you want to happen on mouseover/mouseout ?
Philippe Leybaert
on mouseover the div, the div should be visible else hide the div
Hulk
@Hulk how can you mouseover on somethin if it is hidden? o.O
Agos
A: 

Use the hover function. Its made specially for this usage pattern.

GvS
A: 
$("#playControls").mouseout(function () {
  alert('here');
  $("div").hide(2000);
});

In this part of your code, you hide all divs when you mouseout of div#playControls. The reason you can't fire the mouseover event of your div is because the div is hidden.

Adam Hepton