0

div从左侧列表中的多个实例中选择轮播后,我需要刷新或 jQuery 函数,当页面加载时它会向左滚动,但是当执行函数时,下一个滚动器会停止。

代码是:

<script type="text/javascript">
  $(function() {
    $('#carousel_1').carouFredSel({
      width: '100%',
      auto: {
        items: 1
      },
      prev: '#prev1',
      next: '#next1'
    });

    $('#carousel_2').carouFredSel({
      width: '100%',
      auto: {
        items: 1
      },
      prev: '#prev2',
      next: '#next2'
    });

    $('#carousel_3').carouFredSel({
      width: '100%',
      auto: {
        items: 1
      },
      prev: '#prev3',
      next: '#next3'
    });

    var items = $('.list_switch>li>a').each(function () {
      $(this).click(function () {
        //remove previous class and add it to clicked tab
        items.removeClass('current');
        $(this).addClass('current');

        //hide all content divs and show current one
        $('.carousel').hide().eq(items.index($(this))).show('fast');
      });
    });

    // select the first tab on page load       
    items[0].click();
  });
</script>

演示页面: http ://blogillucent.alwaysdata.net/aaa/coolcarousel.html

4

1 回答 1

0

您可以使用该play事件来恢复所选滑块上的滑动:

例如,

$("#foo").trigger("play");

请参阅此处的文档!

特别是您的代码:

var items = $('.list_switch>li>a').each(function () {
  $(this).click(function () {
    //remove previous class and add it to clicked tab
    items.removeClass('current');
    $(this).addClass('current');

    //hide all content divs and show current one
    $('.carousel').hide().eq(items.index($(this))).show('fast');

    // resume the slide on the selected slider
    $('.carousel').eq(items.index($(this))).trigger("play");
  });
});

通过阅读文档,应该暂停滑块以使用play事件,因此您应该在每次滑块初始化后暂停不可见的滑块:

例如,

$("#foo").trigger("pause");

您可以查看插件自定义事件的代码示例!carouFredSel

于 2012-06-03T13:32:29.660 回答