jQuery delay()不延迟 [英] JQuery delay() not delaying

查看:86
本文介绍了jQuery delay()不延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这会立即清空文本(忽略延迟)?

Why does this empty the text immediately (ignoring delay)?

$('#error_box_text').html('error text').delay(5000).html('')

#

jQuery 1.4

#

jQuery 1.4

推荐答案

delay从不延迟常规方法-只有那些被推送到动画/效果链的方法.如果要延迟html()通话,请使用queue( http://api.jquery.com/队列/):

delay will never delay regular methods - only those who are pushed to the animation/effect chain. If you want to delay your html() call, use queue ( http://api.jquery.com/queue/ ):

$('#error_box_text').html('error text').delay(5000).queue(function() {
   $(this).html('')
});

如果可以的话,那就太好了

It would be nice if you could do

$('#error_box_text').html('error text').delay(5000, function() { $(this).html('') });

但这是不可能的.

这篇关于jQuery delay()不延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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