Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

onclick function call w/timeout



6:09 pm on Jan 5, 2012 (gmt 0)

5+ Year Member

I have a jQuery function that works fine when called via onload/setTimeout or onclick separately, but acts up when I combine onclick w/setTimeout: setTimeout doesn't work the first time I click the link, but works every successive time I click except that the timeout is longer (by 2-3 seconds) than I've set it.

Here's the code I'm using in <head> & <script> tags:

$("#link-id").click(function() { setTimeout($("#func-id").myfunc(), 2000); });

Any ideas?


6:28 pm on Jan 5, 2012 (gmt 0)

5+ Year Member

I may have found the problem, but I can't fix it. The function is a fade-in, which includes some CSS hiding. The full timeout portion of the code above is:

setTimeout($("#func-id").children().hide().myfunc(), 2000);

I've tried tweaking it, but can't get it to work.


12:42 pm on Jan 6, 2012 (gmt 0)

5+ Year Member

RESOLVED - I found a working solution to this.

Featured Threads

Hot Threads This Week

Hot Threads This Month