如何在一个页面上使用多个SlidesJS时识别滑块

时间:2017-02-15 15:51:29

标签: javascript jquery slidesjs

我正在使用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);
      }
    }
  });
});

jsfiddle example

正如您在示例中所看到的,complete回调会更新每个 .slidesjs-slide-number。如何仅更新属于触发完整事件的滑块的幻灯片编号?

0 个答案:

没有答案