JQuery 淡入淡出股票整洁
正在尝试我自己的股票代码,并且已经用完了 JQuery 知识。这些元素应该淡出,然后下一个元素淡入。此时,第一个元素淡出,而第二个和第三个元素一起淡入,并且它们没有循环。显然我错过了一些东西。
<script type="text/javascript">
var elem1 = $('#fader').children();
$(elem1).hide();
$(elem1).first().fadeIn(2000,function(){
$(elem1).delay(4000);
$(elem1).fadeOut(2000, function(){
$(elem1).next().fadeIn(2000);
});
}); </script>
有什么想法吗?
奇妙
Experimenting with my own ticker and have run out of JQuery knowledge. The elements are supposed to fade out then the next one fades in. At the moment the first element fades out whilst the second and third fade in together and their is no loop. Obviously I have missed something.
<script type="text/javascript">
var elem1 = $('#fader').children();
$(elem1).hide();
$(elem1).first().fadeIn(2000,function(){
$(elem1).delay(4000);
$(elem1).fadeOut(2000, function(){
$(elem1).next().fadeIn(2000);
});
}); </script>
Any ideas?
Marvellous
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我做了一个简单的修补程序,可以滚动所有值并停止。也许这就是您正在寻找的东西,或者至少可以帮助您构建自己的东西。 ;)
这是它的 HTML 代码:
脚本本身:
祝你好运! ;D
Well, I made a simple tinker that scrolls all the values and stop. Maybe it's what you're looking for, or, at least, can help you build yours. ;)
Here is it's HTML code:
The script itself:
Good luck! ;D
我认为这是你的选择器。
$(elem1)
引用$('#fader')
的所有子级,因此$(elem1).next()
最终将引用所有可能的“下一个”,在这种情况下,第一个和第二个元素具有“下一个”,分别是第二个和第三个元素。您想要做的是以某种方式跟踪当前显示的元素,然后在时间到时淡出该元素并淡入该元素的下一个元素。
I think it's your selector.
$(elem1)
is referring to all of the children of$('#fader')
, therefore$(elem1).next()
would end up referring to all of the possible "next's", which in this case, the first and second element have "next's", being the second and third elements, respectively.What you want to do is to somehow keep track of which element is the currently shown one, and then when its time, fade that one out and the next one of THAT element in.