如何使用回调

CreateSean

我正在寻找在此脚本上使用回调的方法-第三个回调onSlideChangeStart(swiper)http://idangero.us/swiper/api/#.V9CMp5grJlY但我从未使用过回调方法,并且不知所措。

因此,基本上,我想向页面上其他位置的元素添加/删除一个类,其中另一个元素作为类等于滑动器幻灯片上的数据标签。关于如何开始的任何提示?

我当前工作的js是:

//swiper script for featured director spots
//initialize swiper when document ready
var mySwiper = new Swiper ('.swiper-container', {
    // Optional parameters
    direction: 'horizontal',
    loop: true,

    keyboardControl: true,
    mousewheelControl: true,

    pagination: '.swiper-pagination',
    /*paginationElement: 'span',*/
    paginationClickable: true,



    paginationBulletRender: function (index, className) {
  return '<a class=" ' + className + ' "><i class="fa fa-dot-circle-o active"></i><i class="fa fa-circle non-active"></i></a>';
    }

})

我知道如何添加/删除/切换类,但不确定如何使用回调使其触发。请指教。

所以基本上我需要知道如何添加回调-也许在回调内部有一些在此处或类似处添加更多代码

谢谢你。

欧文海塞尔

应该是这样的:

    mySwiper.on('onSlideChangeStart', function () {
       // do your stuff here
    });
    // do a console log on mySwiper to see what exactly is being passed
    console.log(mySwiper);

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章