提问人:Yoeri Achterbergen 提问时间:9/8/2015 更新时间:9/8/2015 访问量:30
fade 函数 jquery 滑块被钩住了
fade function jquery slider is hooked
问:
我创建的代码可以工作,但是如果您快速单击 de 按钮,滑块就会被钩住。
J查询
$(document).ready(function(){
$(".list div").each(function(e) {
if (e != 0)
$(this).hide();
});
$("#next").click(function(){
if ($(".list div:visible").next().length != 0){
$(".list div:visible").stop().next().stop().fadeIn().prev().stop().fadeOut();
} else {
$(".list div:visible").fadeOut();
$(".list div:first").fadeIn();
}
return false;
});
$("#prev").click(function(){
if ($(".list div:visible").prev().length != 0){
$(".list div:visible").prev().stop().fadeIn().next().stop().fadeOut();
} else {
$(".list div:visible").fadeOut();
$(".list div:last").fadeIn();
}
return false;
});
});
这段代码有什么问题?
希望有人能帮助我。
问候 Yoeri
答:
0赞
D4V1D
9/8/2015
#1
检查您的元素当前是否正在制作动画:
$("#next").click(function(){
if ($(".list div:visible").next().length != 0 && !$(".list div:visible").is(':animated')){ // notice the second condition
$(".list div:visible").stop().next().stop().fadeIn().prev().stop().fadeOut();
} else {
$(".list div:visible").fadeOut();
$(".list div:first").fadeIn();
}
return false;
});
并做同样的事情$("#prev").click();
上一个:数组中的循环数组
下一个:上传图片 PHP SQL
评论
if(!$(elem).is(':animated')) {}