jQuery 睡眠功能?
可能的重复:
Jquery:如何睡眠或延迟?
var main = $('#main_content');
main.append("<img id=\"throbber\" src='/pre_config/css/images/throbber.gif' alt='Loading. Please wait.' />");
sleep(3000);
$("#main_content").load("/pre_config/function.php?type="+type+"piz&count=1", successCallback );
我想在这里睡3秒
sleep is not defined
[Break on this error] sleep(3000);
func2
Possible Duplicate:
Jquery: how to sleep or delay?
var main = $('#main_content');
main.append("<img id=\"throbber\" src='/pre_config/css/images/throbber.gif' alt='Loading. Please wait.' />");
sleep(3000);
$("#main_content").load("/pre_config/function.php?type="+type+"piz&count=1", successCallback );
I want to sleep for 3 seconds here
sleep is not defined
[Break on this error] sleep(3000);
func2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 JavaScript
setTimeout()
。编辑:
要使用
.delay()
,您需要将延迟代码添加到动画队列中。Use a javascript
setTimeout()
.EDIT:
To use
.delay()
, you would need to add the delayed code to an animation queue.请记住,JavaScript 不仅是单线程的,而且与页面渲染共享同一线程。因此,JavaScript 中没有内置的阻塞函数,因为这会导致页面 UI 无响应。
您应该考虑使用计时器,使用
setTimeout()
、setInterval()
或 jQuery 的delay()
。查看 @patrick 的回答了解几个示例。Keep in mind that JavaScript is not only single threaded, but it shares the same thread with the page rendering. Therefore there are no in-built blocking functions in JavaScript, because that would make the page UI unresponsive.
You should consider using timers instead, using
setTimeout()
,setInterval()
, or jQuery'sdelay()
. Check out @patrick's answer for a couple of examples.