I m currently trying to do a menu with submenu. Here is what i want to do.
On hover a link (#mylink) i want to display a div (lets call it "#submenu") right under it. On mouse leave this link a want to execute a function after 5 second.
In this interval of 5 seconds, if i hover my div (#submenu) i want to clearTimeout. So this div won t desapear after 5 seconds.
我的法典如下:
$(document).ready(function()
{
$("#mylink").hover(
function ()
{
$( #submenu ).show();
},
function()
{
var timer = setTimeout(function(){$( #submenu ).hide();}, 5000);
}
);
$("#submenu").hover(
function ()
{
clearTimeout(timer);
},
function()
{
$( #submenu ).show();
}
);
}