所以这是我的周期声明:
function onAfter(curr, next, opts) {
var index = opts.currSlide;
$('.prev')[index == 0 ? 'hide' : 'show']();
$('.next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}
$(function() {
$('#slideshow').cycle({
pager: '#nav',
prev: '.prev',
next: '.next',
after: onAfter,
}).cycle('pause');
});
我希望在after:选项后添加活动类功能。我希望将这两个函数保留在:
之后这是活动的类函数:
$('#slideshow').cycle({
after: function(el, next_el) {
$(next_el).addClass('active');
},
before: function(el) {
$(el).removeClass('active');
}
});
感谢您的帮助!
答案 0 :(得分:0)
您可以通过将第二个函数添加到您的函数并使用适当的参数来组合这两个after
函数:
function onAfter(curr, next, opts) {
var index = opts.currSlide;
$('.prev')[index == 0 ? 'hide' : 'show']();
$('.next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
$(next).addClass('active');
}