简体   繁体   English

如何在easySlider中获取活动索引?

[英]How to get the active index in easySlider?

I'm using easySlider to create a slide show. 我正在使用easySlider创建幻灯片。 but apparently it does not have a callback function or method to get the active index from it. 但显然它没有回调函数或方法来从中获取活动索引。 Is there a way I can determine the active index from anywhere else ? 有没有办法可以从其他任何地方确定活动索引? if not how can I add this functionality to this plugin ? 如果不是,我如何才能将此功能添加到此插件? I'm not good at jQuery. 我不擅长jQuery。 any help is really appreciated. 任何帮助都非常感谢。

To get the current index without modifying the plugin code, you can use something like this: 获取当前索引而不修改插件代码,可以使用如下代码:

var slider = $('#slider'),
    curIndex = Math.round(Math.abs(  parseInt(slider.find('ul').css('marginLeft')) / slider.width()  ));

To listen for the current index, you would need to modify the plugin code. 侦听当前索引,您需要修改插件代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM