当元素触发滑块时为其指定一个类
我有一个 jQuery 滑块,它在左下角使用小缩略图,并允许用户单击缩略图来触发某些幻灯片。
我想在选择时为选定的缩略图指定一个新类,因此本质上是让它们与幻灯片同步。
这可能吗?
这是我的代码。
<script type="text/javascript">
function startGallery() {
var myGallery = new gallery($('myGallery'), {
timed: true
});
}
window.addEvent('domready', startGallery);
</script>
I have a jQuery slider which uses little thumbnails in the bottom left and allows the users to click on the thumbnails to trigger certain slides.
I would like to give the selected thumbnails a new class when selected so essentially giving having them sync up with the slides.
Is this possible?
Here is my code.
<script type="text/javascript">
function startGallery() {
var myGallery = new gallery($('myGallery'), {
timed: true
});
}
window.addEvent('domready', startGallery);
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,您必须编辑
gallery
函数。并在成功选择缩略图后添加此 jQuery 函数$('your-element-id').addClass("Your-New-Class noClass");
。并且在使用$('your-all-thumb-element-class').removeClass("Your-New-Class"); 添加选择类之前,不要忘记从所有缩略图中删除所选类。代码>.并且不要忘记为所有拇指元素分配不同的
id
。Sorry, You have to edit the
gallery
function. And add this jQuery function$('your-element-id').addClass("Your-New-Class noClass");
on successful selection of a thumbnail. And do not forget to remove the selected class from all the thumbnail before adding the selection class using$('your-all-thumb-element-class').removeClass("Your-New-Class");
. And do not forget to assign differentid
to all thumb elements.