Jquery.each使用。队列?
中有该代码
function lshow() {
var delayt = 500;
var showtime = 5000;
var ArrayOfElements = ['.slogan1','.whatwedo','.ekon','.ene', '.ekol', '.sm'];
var i=0;
$.each(ArrayOfElements,function (i,element) {
if($(element).is(':visible')) {
$(element).delay(delayt).hide('slow');
}
if ($(element).is(':hidden')) {
$(element).delay(showtime).show('slow');
}
});
}
我在 jQuery:和 HTML:
<span class="slogan">
<span class="slogan1">my slogan</span><!--Default visible-->
<span class="whatwedo"><!--Default invisible-->
projects <span class="sm">and modernization </span> of something <span class="ekon">fine</span>
<span class="ene">fast</span>
<span class="ekol">smooth</span>
</span>
</span>
CSS:
.whatwedo, .sm, .ene, .ekol {
display: none;
}
,我想将其设置为如下所示:
- 我的口号
fadeOut
- 项目的一些很好的
"fine" fadeOut "fast" fadeIn
- 快速的项目
相同的事情
- 平滑的
- 项目和现代化的项目
但 5 秒后。它显示 “项目和现代化的东西精细快速顺利” 我无法让它工作
I have that code in jQuery:
function lshow() {
var delayt = 500;
var showtime = 5000;
var ArrayOfElements = ['.slogan1','.whatwedo','.ekon','.ene', '.ekol', '.sm'];
var i=0;
$.each(ArrayOfElements,function (i,element) {
if($(element).is(':visible')) {
$(element).delay(delayt).hide('slow');
}
if ($(element).is(':hidden')) {
$(element).delay(showtime).show('slow');
}
});
}
and HTML:
<span class="slogan">
<span class="slogan1">my slogan</span><!--Default visible-->
<span class="whatwedo"><!--Default invisible-->
projects <span class="sm">and modernization </span> of something <span class="ekon">fine</span>
<span class="ene">fast</span>
<span class="ekol">smooth</span>
</span>
</span>
CSS:
.whatwedo, .sm, .ene, .ekol {
display: none;
}
And I want to set it appear like that:
- My slogan
fadeOut
- projects of something fine
"fine" fadeOut "fast" fadeIn
- projects of something fast
same thing
- projects of something smoth
- projects and modernization of something
But after 5 sec. it shows
"projects and modernization of something fine fast smoth"
and i cant get it working
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个 http://jsfiddle.net/Kt38f/
Try this http://jsfiddle.net/Kt38f/
这是另一种方法:
不是将元素放入数组中,而是将应执行的函数放入数组中,并使用
setTimeout
对其进行处理:演示
Here is another way:
Instead of putting the elements in an array, you put the functions that should be executed in an array and process it using
setTimeout
:DEMO
我采取了一些不同的方法。小提琴@ http://jsfiddle.net/SinS3i/xwc9a/1/
I took a little bit of a different approach to it. Fiddle @ http://jsfiddle.net/SinS3i/xwc9a/1/
稍作编辑(http://jsfiddle.net/dVJvc/):
编辑:抱歉我没有看到你的回复。 (代码与上一个 ShankarSangoli 相同)
Little bit edited (http://jsfiddle.net/dVJvc/):
EDIT: Sorry i didnt see yours responses. (THE CODE IS THAT SAME AS last ShankarSangoli)