我创建一个按钮,当它被点击时,移动一些图像,但当我快速点击按钮,jQuery创建一个错误的移动的图像。所以我想禁用按钮,直到.animate()函数没有完成。我尝试写这段代码,但不正确。仅在动画完成后激活按钮上的事件
var next = $('.next');
function nextAction(e){
e.preventDefault();
next.off('click');
if(pellicle.css('left').replace(/[^-\d\.]/g, '') <= -(stepTotalWidth - screenWidth)){
pellicle.animate({
left:'0'
},1000, function(){next.on('click', nextAction);});
}
else {
pellicle.animate({
left:'-=' + screenWidth
},1000);
}
}
next.on('click', nextAction);
而问题是什么? – adeneo 2012-07-31 21:09:44
我的代码没有工作,在某种意义上它不禁止按钮 – 2012-07-31 21:37:37