homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

onclick function call w/timeout

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

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)

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)

RESOLVED - I found a working solution to this.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved