I'm using ResponsiveSlides.js and I am trying to change slides programmatically. I've tried it two ways, and neither have worked.
Calling the plugin's slideTo function from a click event on the thumbnail, passing the index of the slide it should go to.
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");
You can't call the slideTo()
function because it is assigned only to a local variable in the plugin method.
Your second attempt was close, but it looks like the click handler is bound to an <a>
element.
Try:
$('.rslides_tabs').find('a').eq(index).trigger('click');
Where index
is the zero-based index of the slide you want to show.
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".
来源:https://stackoverflow.com/questions/15594790/trigger-responsiveslides-js-programmatically