Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- JQuery Menu help using setTimeout


Fotiman - 3:01 pm on Aug 10, 2012 (gmt 0)


setTimeout will run in a different scope, where "this" is not the same as "this" within the mousover callback function. You just need to create a closure to get around it. You can do that by changing your callback like so:

$(document).ready(function () {
var navTimeout;
$('.mainNav-expand').mouseover(function() {
var that = this;
navTimeout = setTimeout(function() {
$('.mainNavContent').hide();
$(that).children('.mainNavContent').show();
alert("menu test");
}, 500);
}).mouseleave(function() {
clearTimeout(myTimeout);
});

$("#mainNav-bar").mouseout(function() {
$('.mainNavContent').hide();
});

$(".mainNav-close").click(function() {
$('.mainNavContent').hide();
});

});


[jsfiddle.net...]


Thread source:: http://www.webmasterworld.com/javascript/4483540.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com