我正在使用jQuery循环在投资组合页面上构建4个单独的缩略图幻灯片。每个幻灯片都有自己的下一个/上一个按钮。但是每个next / prev按钮只会推进第一个幻灯片,我不知道如何解决这个问题。
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';
}
});
});
答案 0 :(得分: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*/
})
})