jQuery:中断fadeIn()/fadeOut() [英] jQuery: interrupting fadeIn()/fadeOut()

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

问题描述

比方说,我叫$ element.fadeIn(200). 100毫秒后,该页面上发生了一些事情,我想中断该淡入淡出并立即淡出().我该怎么办?

Let's say I've called $element.fadeIn(200). 100 ms later, something happens on that page and I want to interrupt that fade and immediately fadeOut(). How can I do this?

如果调用$ element.fadeIn(200).fadeOut(0)进行调用,则仅在fadeIn()完成后才会发生fadeOut().

If you call calling $element.fadeIn(200).fadeOut(0), the fadeOut() only happens after the fadeIn() has finished.

还有,有没有一种方法可以检查$ element以确定fadeIn()或fadeOut()是否正在运行? $ element是否有任何更改的.data()成员?

Also, is there a way I can examine $element to determine if a fadeIn() or fadeOut() is running? Does $element have any .data() member that changes?

推荐答案

stop()将仅删除尚未执行的动画.

stop() will only remove animations that are not executed yet.

也使用stop(true, true)中断并删除当前动画!

use stop(true, true) to interrupt and remove the current animation too!

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

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