Jquery淡入淡出,将一些元素淡出 [英] Jquery fade in, fade out some elements together

查看:68
本文介绍了Jquery淡入淡出,将一些元素淡出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要淡出并淡出< div> 中的一些子元素,就像在Toni Almeida'a回答:

I need to fade out and fade in some child elements in <div> like in Toni Almeida'a answer:

淡入淡出图片

 <div class="display" id="slideshow">
            <a class="slice" href="myUrl1">
                <div class="caption">Some text1...</div>
                <img src="AnyUrl1" width="360" height="300"/>
            </a>

            <a class="slice" href="myUrl2">
                <div class="caption">Some text2...</div>
                <img src="AnyUrl2" width="360" height="300"/>
            </a>

            <a class="slice" href="myUrl3">
                <div class="caption">Some text3...</div>
                <img src="AnyUrl3" width="360" height="300"/>
            </a>
           .......
</div>

如何编辑该答案中的代码?

How should I edit the code in that answer?

推荐答案

这是我的 js 代码经过修改后可以使用 html

Here is my js code modified to work with your html:

var count = 1;
setInterval(function() {
    count = ($("#slideshow").find(".slice:nth-child("+count+")").fadeOut().next().length == 0) ? 1 : count+1;
    $("#slideshow").find(".slice:nth-child("+count+")").fadeIn();
}, 2000);

小提琴: http://jsfiddle.net/HewAd/

这篇关于Jquery淡入淡出,将一些元素淡出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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