jQuery等待文档准备就绪后等待x秒 [英] JQuery wait x seconds after document ready

查看:91
本文介绍了jQuery等待文档准备就绪后等待x秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码将等到dom准备就绪

following code waits till dom ready

jQuery(document).ready(function(){

在文档准备好后,我需要写些什么让jquery函数的执行等待2秒钟?

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 conflict between multiple instances of a plugin.

THX

推荐答案

用对setTimeout的调用来包装现有函数,即替换当前的:

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

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

使用

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

这篇关于jQuery等待文档准备就绪后等待x秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆