我希望在此脚本上使用回调 - 第三个回调 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);
关于javascript - 如何使用回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39379782/