Jquery Testimonial fader does not work smoothly

后端 未结 3 1214
心在旅途
心在旅途 2021-01-27 02:58

I use jquery to rotate my div one by one using fade effect but the effect is not smooth it jumps up and down and then display here is my fiddle.

http://jsfiddle.net/xXRw

3条回答
  •  無奈伤痛
    2021-01-27 03:21

    Use the callback function:

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

    http://jsfiddle.net/xXRwA/3/

    Note that you can also cache the object and show/hide the elements based on their indexes. This can be more efficient(if it matters) than querying the DOM and creating many jQuery objects which is not necessary here. Something like this.

提交回复
热议问题