jQuery延迟函数中断 [英] jQuery delay function interrupt

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

问题描述

我在jQuery中有一个淡入淡出的弹出窗口,如果没有被用户解雇,它会在10秒内淡出。

I have a pop-up window in jQuery that fades in, and will fade out in 10 seconds if not dismissed by the user.

我有代码:

$modalElement.fadeIn(1000).delay(10000).fadeOut(1000);

这适用于淡入,延迟和淡出 - 但'close'表单上的按钮在超时后才起作用!

And this works fine for the fade in, delay and fade out - but the 'close' button on the form doesnt work until after the timeout!

我需要'关闭'按钮来中断延迟,这样用户就可以阅读弹出窗口并自行关闭,比如5秒 - 然后如果他们没有关闭它自己,然后它将在10秒延迟后自动关闭。

I need the 'close' button to interupt the delay, so that the user can read the pop up and close it themselves, say, at 5 seconds - and then if they havent closed it themselves, then it will close automatically after the 10 second delay.

任何想法如何做到这一点?

Any ideas how to do this?

推荐答案

您可以使用 .clearQueue() 方法。

You can use the .clearQueue() method.

在您的关闭处理程序中,您可以这样做:

In your close handler you can do this:

$modalEleement.clearQueue();

默认情况下, .delay() .clearQueue() fx 队列上运行,但您可以传递自定义队列名称。

By default, both .delay() and .clearQueue() operate on the fx queue, but you can pass custom queue names.

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

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