jQuery的淡入淡出与循环和延迟 [英] JQuery fade with loop and delay

查看:95
本文介绍了jQuery的淡入淡出与循环和延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个Divs叠在一起.

I have 2 Divs stacked on top of each other.

我需要一个非常简单的函数,该函数将:

I need a really simple function that will:

a)等待3秒钟,然后 b)淡出顶部Div以显示第二个Div c)再次等待3秒钟,然后 d)再次淡入最高级Div e)再次循环播放

a) Wait for 3 seconds and then b) FadeOut the top Div to reveal the second Div c) Wait 3 seconds again and then d) FadeIn the top Div again e) Loop back again

任何人都可以提供任何建议吗?

Can anyone offer any advice?

非常感谢

推荐答案

这是尝试.

function foo() {
    jQuery("#mydiv").animate({opacity: 1.0}, {duration: 3000})
        .animate({opacity: 0}, {duration: 3000})
        .animate({opacity: 0}, {duration: 3000})
        .animate({opacity: 1.0}, {duration: 3000, complete: foo})
}

注意:要暂停,只需在目标值与当前相同的属性上调用动画.最后一个动画调用与回调相同的功能.

Note: To pause, just call animate over a property with the same target value as it is right now. The last animate calls the the same function as callback.

PS:随着时间的推移,它会导致堆栈溢出吗?

PS: Does it cause stack overflow over time?

这篇关于jQuery的淡入淡出与循环和延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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