大家好,我需要一些帮助,对于 jquery 还是很陌生
我正在使用 cycle add-on 到目前为止我有以下内容 我正试图找到添加悬停的方法
所以当用户将鼠标悬停在菜单中的链接上时,它正在循环通过它暂停循环并切换到悬停,即用户控制
但在鼠标移开一段时间后它会恢复
var n=0
var dn=1
$(document).ready(function() {
$('.slideshow')
.cycle({
fx: 'fade',
speed: 500,
timeout: 3000,
before: function(curr, next, opts) {
n=n+1;
if (n>5) {n=1;dn=5}
$('#item'+dn).removeClass("active");
$('#item'+(n)).addClass("active");
dn=n;
}
});
$(".slideshow").cycle('resume');
$(".slideshow").mouseover(function(){
$(this).cycle('pause');
}).mouseout(function(){
$(this).cycle('resume');
});
});
如有任何帮助,将不胜感激
最佳答案
$(".slideshow").hover(function(){
clearTimeout();
$(this).cycle('pause');
}, function(){
setTimeout(function(){
$(this).cycle('resume');
}, 500);
});
当前设置在 500 毫秒未悬停在幻灯片上后恢复。
关于javascript - 具有悬停效果的 jquery 循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6924206/