[jQuery] jQuery Delay or SetTimeout equivalent

[jQuery] jQuery Delay or SetTimeout equivalent

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=484550607-19072006><FONT face=Verdana
color=#0000ff size=2>Following up on my previous reply... :-) I didn't take a
close enough look at your second example. It is much closer to the mark, fixing
the problem I mentioned where you were not passing a function as the second
argument to .hover(). So it <EM>is</EM> really something
different.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=484550607-19072006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=484550607-19072006><FONT face=Verdana
color=#0000ff size=2>Take care of the "this" issue that I mentioned in my
other reply and you should be much closer to working code.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=484550607-19072006><FONT face=Verdana
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=484550607-19072006><FONT face=Verdana
color=#0000ff size=2>-Mike</FONT></SPAN></DIV><FONT face=Verdana color=#0000ff
size=2></FONT><FONT face=Verdana color=#0000ff size=2></FONT><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com] <B>On Behalf Of </B>Eric
Ferraiuolo<BR><B>Sent:</B> Tuesday, July 18, 2006 10:21 PM<BR><B>To:</B>
jQuery Discussion.<BR><B>Subject:</B> Re: [jQuery] jQuery Delay or SetTimeout
equivalent<BR></FONT><BR></DIV>
<DIV></DIV>I have tried to get this to work, but this doesn't seem to be
working...that's why i was asking (i wouldn't have asked if i haven't tried
for some time)<BR><BR>    //    Help IE
understand :hover and animate menu<BR>    $("#sectionMenu
li.menuSection").not(".expanded")<BR>   
.hover(function(){<BR>       
$(this).addClass("opened")<BR>       
$(this).find("ul").fadeIn("fast");<BR>   
},setTimeout(function(){<BR>       
$(this).find("ul")<BR>           
.fadeOut("normal",function(){<BR>       
       
$(this).css("visibility","visible");<BR>       
        $(this).parents("li.menuSection
").removeClass("opened");<BR>       
    });<BR>    }, 1000));<BR><BR><BR>This didn't
work either (as it shouldn't its really nothing
different):<BR><BR>    //    Help IE understand
:hover and animate menu<BR>    $("#sectionMenu
li.menuSection").not(".expanded")<BR>   
.hover(function(){<BR>       
$(this).addClass("opened")<BR>       
$(this).find("ul").fadeIn("fast");<BR>    },function(){
<BR>       
setTimeout(function(){<BR>       
    $(this).find("ul")<BR>       
       
.fadeOut("normal",function(){<BR>       
           
$(this).css("visibility","visible");<BR>       
           
$(this).parents("li.menuSection").removeClass("opened");<BR>   
           
});<BR>        }, 1000)<BR>   
});<BR><BR><BR>Both of the above code snippts, don't end up executing the
second function on the hover event. <BR><BR>I must be mixing the code wrong,
any ideas?<BR><BR><BR><BR>Eric<BR><BR><BR><BR>
<DIV><SPAN class=gmail_quote>On 7/19/06, <B class=gmail_sendername>Michael
Geary</B> <<A href="mailto:Mike@geary.com">Mike@geary.com </A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">>
So is there a way with jQuery to pause JS like the<BR>> setTimeout()
function? <BR><BR>Yes, there is:<BR><BR>   setTimeout( function()
{<BR>      alert( 'timer!' );<BR>  
}, 1000 );<BR><BR>But... That's just a plain old setTimeout! What is the
*jQuery* way to do<BR>it?<BR><BR>   setTimeout( function() {
<BR>      alert( 'timer!' );<BR>  
}, 1000 );<BR><BR>OK, I'm being a bit silly here. Not trying to poke fun at
your question;<BR>it's a perfectly reasonable one , and similar questions
come up on the list<BR>quite often.<BR><BR>Generally, when the built-in
JavaScript way of doing something is perfectly<BR>good and can't really be
improved upon, then there probably isn't a "jQuery"<BR>way to do it.
setTimeout falls in that category - it works fine the way it <BR>is, so just
use it.<BR><BR>You can mix and match jQuery code with "ordinary" JavaScript
code to your<BR>heart's content. After all, jQuery code *is* ordinary
JavaScript
code.<BR><BR>-Mike<BR><BR><BR>_______________________________________________
<BR>jQuery mailing list<BR><A
href="mailto:discuss@jquery.com">discuss@jquery.com</A><BR><A
href="http://jquery.com/discuss/">http://jquery.com/discuss/</A><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/






























































































    • Topic Participants

    • mike