.delay()和.setTimeout() [英] .delay() and .setTimeout()

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

问题描述

根据.delay()上的jQuery文档,

According to jQuery document on .delay(),

.delay()方法最适合在排队的jQuery之间进行延迟 效果.因为它是有限的,例如,它没有提供一种方法来 取消延迟-.delay()不能替代JavaScript的本机 setTimeout函数,可能更适合某些用途 案例.

The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.

有人可以对此进行扩展吗?什么时候使用.delay()更合​​适,什么时候使用.setTimeout()更好?

Could someone please expand on this? When is it more appropriate to use .delay(), and when is it better to use .setTimeout()?

推荐答案

我认为您发布的内容确实可以解释自己.

I think what you posted explains itself really.

.delay()用于jQuery效果,包括动画.

Use .delay() for jQuery effects including animations.

setTimeout()最好用于其他所有内容.例如,当您需要在某个经过的时间触发事件时.

setTimeout() is best used for everything else. For example when you need to trigger an event at a certain elapsed time.

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

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