0

Im creating a drop down menu and i want to know if there is anyway to implement the following:

I need to keep the sub-menu open for like 1 sec if the user moves the mouse away from the tab he selected. Much likely like in current intel web page www.intel.com , here u hover over menu, but if u take the mouse away from the tab or the sub-menu is opens it takes a few to hide the sub menu.

Im using .mouseover from jquery to show the menu (a div) but i cant find a way to make it stay for a few moments.

Thanks in advance

  • I met the similar question, you could find out the answer [here][1] [1]: http://stackoverflow.com/questions/4414638/i-want-the-div-show-when-mouse-hover-on-another-and-disppear-automatic-after-few – Rong Yong Sep 21 '11 at 03:02

1 Answers1

0

This may be of service What is the JavaScript version of sleep()?

If you want to do something in the interim setTimeout() takes the arguments as shown where continue execution is another subroutine. If you just want this one tab to work this way have mouseover call doStuff and set a boolean (e.g. mouseStillIn) to TRUE. When the mouse exits set this boolean to FALSE, call a recursive function everytime mouseStillIn is TRUE.

e.g.


var mouseStillIn : boolean = false;

function MouseIn()
{
mouseStillIn=true;
CheckMouse();
}

function CheckMouse()
{
if(mouseStillIn)
{
setTimeout(CheckMouse, 1000);
}
}

function MouseOut()
{
mouseStillIn=false;
}
Community
  • 1
  • 1
awiebe
  • 3,758
  • 4
  • 22
  • 33