0

我正在使用 jQuery 循环在投资组合页面上构建 4 个单独的缩略图幻灯片。每个幻灯片都有它自己的下一个/上一个按钮。但是每个下一个/上一个按钮只会推进第一个幻灯片,我不知道如何解决这个问题。

HTML 代码:(重复 4 次)

<div class="slider">
<div class="slides">
    <div>
    <img src="images/portfolio/ident1.jpg" alt=""/>
    <img src="images/portfolio/ident2.jpg" alt=""/>
    <img src="images/portfolio/ident3.jpg" alt=""/>
    <img src="images/portfolio/ident4.jpg" alt=""/>
            </div>
     </div><!--end of slides-->
 </div><!--end of slider-->
 <img src="images/arrow-L.png" alt="Left" class="slider-arrow-left"/>
 <img src="images/arrow-R.png" alt="Right" class="slider-arrow-right"/>

jQuery代码:

$(document).ready(function(){
     $(".call-button").toggle(
function() {
$(this).animate({ left: "0" }, 1000 );
}, 
function() { 
$(this).animate({ left: "-225px" }, 1000 );
});

    $('.slides').cycle({ 
        fx:      'scrollHorz', 
        speed:  'slow', 
        timeout: 0, 
        nowrap: true,
        pause:   1,
        prev: $('.slider-arrow-left'),
        next: $('.slider-arrow-right'),
        cssBefore:{ 
            top: 0,
            opacity: 1,
            display: 'block'
        }, 
        animOut: {  
            top: 360
        },
        before: function(curr, next, opts){
            var $curr = $(curr);
            var $next = $(next);
        },
        pause: 1,
        pager: '.slider-controls',
        pagerAnchorBuilder: function (idx, slide) {
            return '.slider-controls li:eq(' + idx + ') a';
        }
    });
});
4

1 回答 1

0

为了隔离每个节目的控件,您需要遍历每个节目并在每个实例中定义控件:

/* assumes you have "slider" DIV (parent() in code below) wrapped around each show*/
$('.slides').each(function(){
   /* look for controls only within this instance*/
  var nextBtn=$(this).parent().find('.slider-arrow-left');
   $(this).cycle({ 
       next: nextBtn
       /* do same for pager and prev*/
   })
})
于 2013-01-12T18:20:32.907 回答