jQuery 循环插件帮助
有人可以帮我做两件事之一吗?
1) 使循环插件突出显示相关按钮。
- 或 -
2) 单击按钮后使循环插件停止旋转。
我的问题是图像循环,然后我单击一个按钮。循环继续,但之前选择的按钮保持突出显示。任何一种修复都是合适的。也许修复 1 更好,但我真的很容易。
这是我现在所拥有的。
var $container = $('#slider .inner').cycle({
fx: 'scrollHorz',
speed: 300,
timeout: 4000
});
$container.children().each(function(i) {
// There are only 3 images, this is to stop a random 4th button being created.
if (i != 3) {
$('<input type="button" value="'+(i+1)+'" />')
// append it to button container
.appendTo(bc)
// bind click handler
.click(function() {
// cycle to the corresponding slide
$container.cycle(i);
$(".home_buttons input").removeClass('selected');
$(this).addClass('selected');
return false;
});
}
});
Can someone help me do one of two things.
1) Make the cycle plugin highlight the relevant button.
- or -
2) Make the cycle plugin stop rotating once a button is clicked.
My problem is that the images cycle, then I click a button. The cycling resumes but the previously selected button stays highlighted. Either fix will be suitable. Perhaps fix 1 is preferable but I am easy really.
Here is what I have at the moment.
var $container = $('#slider .inner').cycle({
fx: 'scrollHorz',
speed: 300,
timeout: 4000
});
$container.children().each(function(i) {
// There are only 3 images, this is to stop a random 4th button being created.
if (i != 3) {
$('<input type="button" value="'+(i+1)+'" />')
// append it to button container
.appendTo(bc)
// bind click handler
.click(function() {
// cycle to the corresponding slide
$container.cycle(i);
$(".home_buttons input").removeClass('selected');
$(this).addClass('selected');
return false;
});
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用循环分页器功能将为您构建列表并将“activeSlide”作为类添加到该项目:分页器只需将:(
或您想要内置列表的任何容器)添加到循环内的选项中。此处演示:x http://jquery.malsup.com/cycle/pager2.html虽然听起来您不一定需要页面锚位
If you use cycles pager function will build the list for you and add 'activeSlide' as a class to that item: pager just add:
(or whatever container you want the list built in) to your options within cycle. Demo here: x http://jquery.malsup.com/cycle/pager2.html though it sounds like you won't nessecarily need the page anchor bit