以编程方式触发ResponsiveSlides.js [英] Trigger ResponsiveSlides.js programmatically
问题描述
我正在使用 ResponsiveSlides.js ,并且我正在尝试以编程方式更改幻灯片.我已经尝试了两种方法,但都没有效果.
I'm using ResponsiveSlides.js and I am trying to change slides programmatically. I've tried it two ways, and neither have worked.
-
从缩略图上的click事件中调用插件的 slideTo 函数,并传递应访问的幻灯片的索引.
Calling the plugin's slideTo function from a click event on the thumbnail, passing the index of the slide it should go to.
在<li>
上使用.trigger("click")
对应于它应该去的幻灯片的索引,例如:
Use .trigger("click")
on the <li>
corresponding to the index of the slide it should go to, ex:
$(.rslides_tabs li").eq($ theIndex).trigger("click");
$(".rslides_tabs li").eq($theIndex).trigger("click");
推荐答案
您不能调用slideTo()
函数,因为该函数仅分配给plugin方法中的局部变量.
You can't call the slideTo()
function because it is assigned only to a local variable in the plugin method.
您的第二次尝试已结束,但似乎单击处理程序已绑定到<a>
元素.
Your second attempt was close, but it looks like the click handler is bound to an <a>
element.
尝试:
$('.rslides_tabs').find('a').eq(index).trigger('click');
index
是要显示的幻灯片的从零开始的索引.
Where index
is the zero-based index of the slide you want to show.
注意:如果您为名称空间"选项传递了一个值,则必须将类名从"rslides_tabs"更改为您传递的任何值+"_ tabs".因此,如果您为选项传递了( namespace: 'mynamespace' }
,则该类将为"mynamespace_tabs".
Note: If you passed a value in for the "namespace" option, then you would have to change the class name from "rslides_tabs" to whatever value you passed + "_tabs". So if you passed ( namespace: 'mynamespace' }
for the options, the class would be "mynamespace_tabs".
这篇关于以编程方式触发ResponsiveSlides.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!