在此演示中,如果用户在动画期间单击,则将多次触发click事件。
因此,如果用户单击了三次,则在每个动画完成后,单击功能将启动动画三次。
我该如何做click event wouldn't be triggered if the user clicks during the animation
呢?
有几种方法可以执行此操作,一种方法是设置一个标志,该标志将跟踪按钮是否被单击:
var clicked = false;
$('elm').click(function(){
if(!clicked){
clicked = true;
// continue with animation//
$('something').animate({
//animation
}, time, function(){
// at the end of animation
clicked = false
});
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句