我正在使用SlidesJS在一个页面上显示多个滑块。当滑块转换到下一张幻灯片时,我想使用回调。如何识别触发事件的滑块实例?
这是我用来初始化SlidesJS的JS代码:
$(function() {
$('.slides').slidesjs({
width: 940,
height: 528,
callback: {
loaded: function(number) {
// Use your browser console to view log
console.log('SlidesJS: Loaded with slide #' + number);
// Show start slide in log
$('#slidesjs-log .slidesjs-slide-number').text(number);
},
start: function(number) {
// Use your browser console to view log
console.log('SlidesJS: Start Animation on slide #' + number);
},
complete: function(number) {
// Use your browser console to view log
console.log('SlidesJS: Animation Complete. Current slide is #' + number);
// Change slide number on animation complete
$('.slidesjs-log .slidesjs-slide-number').text(number);
}
}
});
});
正如您在示例中所看到的,complete
回调会更新每个 .slidesjs-slide-number
。如何仅更新属于触发完整事件的滑块的幻灯片编号?