Jquery鉴定音量控制器工作不顺畅

Jquery鉴定音量控制器工作不顺畅,jquery,fade,testimonials,Jquery,Fade,Testimonials,我使用jquery使用淡入效果逐个旋转div,但效果并不平滑 它上下跳跃,然后显示 这是我的小提琴 添加以下CSS: .testimonials { position: relative; } .testimonials .a { position: absolute; } 这将使所有的.a位于一个和另一个之上 演示:添加以下CSS: .testimonials { position: relative; } .testimonials .a { posit

我使用jquery使用淡入效果逐个旋转div,但效果并不平滑 它上下跳跃,然后显示 这是我的小提琴

添加以下CSS:

.testimonials {
    position: relative;
}

.testimonials .a {
    position: absolute;
}
这将使所有的.a位于一个和另一个之上

演示:

添加以下CSS:

.testimonials {
    position: relative;
}

.testimonials .a {
    position: absolute;
}
这将使所有的.a位于一个和另一个之上


演示:

只需使用间隔来显示和隐藏方法:

 $('.testimonials div:first').show();

setInterval(function(){ $('.testimonials div:first-child').fadeOut(1000).next('div').fadeIn(1000).end().appendTo('.testimonials') },3000); 
或者更好,如果您不想查看跳转:

 $('.testimonials div:first').show();

setInterval(function(){ $('.testimonials div:first-child').fadeOut(1000).next('div').delay(1000).fadeIn(1000).end().appendTo('.testimonials') },3000);

jsiddle:

只需使用一个间隔来显示和隐藏方法:

 $('.testimonials div:first').show();

setInterval(function(){ $('.testimonials div:first-child').fadeOut(1000).next('div').fadeIn(1000).end().appendTo('.testimonials') },3000); 
或者更好,如果您不想查看跳转:

 $('.testimonials div:first').show();

setInterval(function(){ $('.testimonials div:first-child').fadeOut(1000).next('div').delay(1000).fadeIn(1000).end().appendTo('.testimonials') },3000);

jsidle:

使用回调函数:

setInterval(function(){ 
   $('.testimonials div:first-child').fadeOut(function() {
        $(this).next('div').fadeIn().end().appendTo('.testimonials');
   }); 
},3000);

请注意,您还可以缓存对象,并根据其索引显示/隐藏元素。如果这比查询DOM和创建许多jQuery对象更重要的话,那么这会更有效,而在这里,jQuery对象是不必要的。类似于。

使用回调函数:

setInterval(function(){ 
   $('.testimonials div:first-child').fadeOut(function() {
        $(this).next('div').fadeIn().end().appendTo('.testimonials');
   }); 
},3000);
请注意,您还可以缓存对象,并根据其索引显示/隐藏元素。如果这比查询DOM和创建许多jQuery对象更重要的话,那么这会更有效,而在这里,jQuery对象是不必要的。差不多