开发者

JQuery wait x seconds after document ready

开发者 https://www.devze.com 2023-02-18 15:40 出处:网络
following code waits till dom ready jQuery(document).ready(function(){ what do i have to write to simple let the execution of the jquery function wait for 2 seconds after the document is ready?

following code waits till dom ready

jQuery(document).ready(function(){

what do i have to write to simple let the execution of the jquery function wait for 2 seconds after the document is ready?

i need this to narrow down a confl开发者_如何学运维ict between multiple instances of a plugin.

THX


Wrap your existing function with a call to setTimeout, ie, replace your current:

jQuery(document).ready(function() {
     ....
});

with

jQuery(document).ready(function() {
    setTimeout(function() {
         ....
    }, 2000);
});


You can use

$(window).load(function(){}); 

instead of

$(document).ready(function(){});

I took reference from jquery forum


By using window.setTimeout.


Read about setTimeOut(). http://www.w3schools.com/jsref/met_win_settimeout.asp

0

精彩评论

暂无评论...
验证码 换一张
取 消