我正在创建一个图像横幅,其中有滚动链接,改变文本和图像。我需要做的是每隔5秒在5个图像中旋转一次,但在鼠标悬停时,它会暂停旋转,并将您带到用户选择的图像。我的鼠标悬停代码是:
$("#main_nav li").mouseover( function() {
$(".navigation_main, .main_info").each (function() {
$(this).removeClass("on").addClass("off");
});
$("#"+$(this).attr("id")).removeClass("off").addClass("on");
$("#"+$(this).attr("id")+"_images").removeClass("off").addClass("on");
$("#"+$(this).attr("id")+"_text").removeClass("off").addClass("on");
$("#"+$(this).attr("id")+"_a").removeClass("off").addClass("on");
});如果能帮助你让它旋转,那就太好了。
非常感谢
发布于 2009-10-12 16:17:05
下面是jQuery的cycle插件如何做到这一点:
示例:http://malsup.com/jquery/cycle/pagerHover.html
如果设置了pause选项,则hover会递增一个名为cyclePause的变量,从而导致幻灯片不旋转:
if (opts.pause)
$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});稍后,将选中循环暂停。如果是的话,那就没有进步了。
case 'pause':
cont.cyclePause = 1;
return false;
case 'resume':
cont.cyclePause = 0;
if (arg2 === true) { // resume now!
options = $(cont).data('cycle.opts');
if (!options) {
log('options not found, can not resume');
return false;
}
if (cont.cycleTimeout) {
clearTimeout(cont.cycleTimeout);
cont.cycleTimeout = 0;
}
go(options.elements, options, 1, 1);
}
return false;https://stackoverflow.com/questions/1555444
复制相似问题