Javascript 文本旋转器在最后一张幻灯片上闪烁

Javascript 文本旋转器在最后一张幻灯片上闪烁,javascript,jquery,css,Javascript,Jquery,Css,我已经创建了一个文本旋转器,它使用速度和间隔来确定文本旋转的速度和时间。一切似乎都正常,只是我唯一的问题是在最后和第一次转换之间的闪烁。换言之,我可以同时看到新旧条目。有人能帮我避免这个吗? 我的 我的JQuery代码是: (function($) { $(document).ready(function(){ //<![CDATA[ (function($) { $.fn.rotator = function(settings) {

我已经创建了一个文本旋转器,它使用速度和间隔来确定文本旋转的速度和时间。一切似乎都正常,只是我唯一的问题是在最后和第一次转换之间的闪烁。换言之,我可以同时看到新旧条目。有人能帮我避免这个吗? 我的

我的JQuery代码是:

    (function($) {


  $(document).ready(function(){

    //<![CDATA[

    (function($) {
      $.fn.rotator = function(settings) {
        settings = jQuery.extend({
          interval: 5000,
          speed:800,
        }, settings);

        return this.each(function() {
          var $t = $(this),
              $item = $t.children().addClass('item').hide();

          $t.addClass('rotator');

          if ($item.length > 1) {
            $item.first().addClass('current').fadeIn(settings.speed);
            setInterval(function() {
              var c = $t.find('.current');
              if (c.next().length === 0) {
                c.removeClass('current').fadeOut(settings.speed);
                $item.first().addClass('current').fadeIn(settings.speed);
              } else {
                c.fadeOut(settings.speed, function () {
                  $(this).removeClass('current')
                    .next().addClass('current')
                    .fadeIn(settings.speed)
                });
              }
            }, settings.interval);
          }
        });
      };
    })(jQuery);

    // Execute here!
    $(function() {
      $('#slider').rotator();
    });
    //]]>



  });


})(jQuery);
(函数($){
$(文档).ready(函数(){
// 1) {
$item.first().addClass('current').fadeIn(settings.speed);
setInterval(函数(){
var c=$t.find('.current');
如果(c.next().length==0){
c、 removeClass(“当前”).fadeOut(设置.速度);
$item.first().addClass('current').fadeIn(settings.speed);
}否则{
c、 淡出(设置、速度、功能(){
$(this.removeClass('current'))
.next().addClass('current')
.fadeIn(设置.速度)
});
}
},设置。间隔);
}
});
};
})(jQuery);
//在这里执行!
$(函数(){
$(“#滑块”).rotator();
});
//]]>
});
})(jQuery);