I’m trying to add delay to a simple drop down menu. With the following code I get a delay but wrong kind. When I move my mouse over the menu really fast, it delays it but still opens it after the 300ms. The right behavior would be to open the menu when the mouse has hovered 300ms on it, same when leaving it.
$('#menu-item-1226:not(.parent-pageid-1225 #menu-item-1226)').hover(function(){
var menu = this;
setTimeout(function(){
$(menu).find('ul').slideToggle(100);
}, 300);
});
Do I have to stop it somehow or what is the right approach here?
Thanks in advance
This is probably what you are looking for, however using the Jquery Plugin HoverIntent will work as well, and maybe even better.
without hover intent:
});
with hover intent plugin