以编程方式触发ResponsiveSlides.js [英] Trigger ResponsiveSlides.js programmatically

查看:108
本文介绍了以编程方式触发ResponsiveSlides.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

  1. 从缩略图上的click事件中调用插件的 slideTo 函数,并传递应访问的幻灯片的索引.

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆