Hi, thank you. I wasn't aware that setTimeout has a return value. Thanks.
Regards Matthias MorningZ schrieb: > "PS: maybe a dumb question but I'm pretty new to jquery" > > Well, the solution doesn't really have anything to do with jQuery > > instead of : > > $(".classoflinks").hover(function() { > $("#myDiv").show(); > }, function() { > setTimeout(function() { $("#myDiv").hide(); }, 4000); > }); > > > this will hold the setTimeout in a later-accessible object > > var _PendingHide; > $(".classoflinks").hover(function() { > $("#myDiv").show(); > }, function() { > _PendingHide = setTimeout(function() { $("#myDiv").hide(); }, > 4000); > }); > > > which in turn gives you the ability to cancel that "hide()" command > > if (_PendingHide) { clearTimeout(_PendingHide ); } > > > > On Dec 5, 7:55 am, Matthias Coy <[EMAIL PROTECTED]> wrote: >> Hi there, >> >> I have a relativly simple question, first some code: >> >> $(".classoflinks").hover(function() { >> $("#myDiv").show();}, function() { >> >> setTimeout(function() { $("#myDiv").hide(); }, 4000); >> >> }); >> >> so that's what I'm doing. Mouseover shows the div, mouseout hides the >> div after 4 seconds. Now the tricky part: >> >> When I hover over the shown div, I want to stop the hiding. Something like: >> >> $("#myDiv").hover(function(){ >> $(this).stopHide();}, function() { >> >> setTimeout(function() { $("#myDiv").hide(); }, 4000); >> >> }); >> >> what do I have to do instead of my not existing function "stopHide()"? >> >> Sincerely >> Matthias >> >> PS: maybe a dumb question but I'm pretty new to jquery. >