Idangerous swiper插件有2个滑块/ 1个导航

时间:2014-04-09 14:02:53

标签: swiper

我实际上正在使用swiper idangero'us插件(带有“进度”扩展名),我想知道一些事情:

是否可以为2个不同的滑块设置相同的导航按钮?

现在我正在尝试做类似的事情:

$(function(){
              var mySwiper = $('.swiper-container').swiper();
              var mySwiper2 = $('.swiper-container-genders').swiper();

              $('.swiper-arrow-right').click(function(){
                mySwiper.swipeNext();
                mySwiper2.swipeNext();                
              });
              $('.swiper-arrow-left').click(function(){
                mySwiper.swipePrev();
                mySwiper2.swipePrev();
              });

但它没有用!

这里是经典代码:

              $(document).on('click', '.swiper-arrows', function(e){
            e.preventDefault();
            var index = $(this).attr('data-id');
            if ($(this).is('.swiper-arrow-right')) {
              $('.swiper-container[data-id="'+index+'"]').data('swiper').swipeNext();
            } else {
              $('.swiper-container[data-id="'+index+'"]').data('swiper').swipePrev();
            }
        });  

有任何帮助吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

您应该将切换“箭头”分隔为单独的切换。

  

$(函数(){               var mySwiper = $('。swiper-container')。swiper();               var mySwiper2 = $('。swiper-container-genders')。swiper();

         $('.swiper-arrow-right').click(function(){
           mySwiper.swipeNext();
           mySwiper2.swipeNext();                
         });
         $('.swiper-arrow-left').click(function(){
           mySwiper.swipePrev();
           mySwiper2.swipePrev();
         });
         $('.swiper-arrow-right2').click(function(){
           mySwiper2.swipeNext();                
         });
         $('.swiper-arrow-left2').click(function(){
           mySwiper2.swipePrev();
         });