jQuery delay()函数 [英] Jquery delay() function

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

问题描述

我有一些jquery,正在尝试对其施加延迟,但似乎无法使其正常工作.

I have some jquery and am trying to apply a delay to it but can't seem to get it to work.

当前的jquery如下...

The current jquery is as follows...

image.css({"visibility" : "hidden"}).removeClass("image-background");

我已经尝试根据jquery网站(http://api.jquery.com/delay/)对此进行修改,以应用延迟...

and I have tried ammending this according to the jquery website (http://api.jquery.com/delay/) to apply the delay...

image.delay(800).css({"visibility" : "hidden"}).removeClass("image-background");

但这似乎没有什么区别.

but this doesn't seem to make any difference.

有人可以看到这个问题吗?或者我该如何解决该问题?

Can anyone see a problem with this? Or how I could fix the problem?

谢谢.

推荐答案

delay()函数仅适用于在元素上排队的操作.最常见但并非总是如此,这些是由animate()方法创建的动作.在这种情况下,请使用setTimeout在指定的时间间隔后运行一些代码.

The delay() function only applies to actions queued on the element. Most commonly, but not always, these are actions created by the animate() method. In this case, use setTimeout to run some code after a specified interval.

尝试一下:

setTimeout(function() {
    image.css({"visibility" : "hidden"}).removeClass("image-background");
}, 800);

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

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