I'm not big on javascript/jquery, but what I'm trying to do is simply add a timout to a mouseenter
function, which I can do no dramas, but I also want to clear the timeout if the user leaves the element before the timeout expires - mainly to allow for cursor skipping over the triggering element.
Code is below (mouseenter works, mouseleave works but doesn't clear the timeout):
$(document).ready(function() {
var timeout;
$('#mainMenu ul li').mouseenter(function() {
var dropTab = 'ul.' + this.id + 'Dropdown';
timeout = setTimeout( function(){
$(dropTab).slideToggle("fast") }, 500
);
});
$('#mainMenu ul li').mouseleave(function() {
clearTimeout(timeout);
var dropTab = 'ul.' + this.id + 'Dropdown';
setTimeout( function(){
$(dropTab).slideToggle("fast") }, 250
);
});
});