开发者

Tell jQuery to ignore clicks during an animation sequence

开发者 https://www.devze.com 2022-12-23 12:24 出处:网络
I\'m in the midst of writing a slide show app (click a button, and you slide through a list of images) for jQuery, but I\'ve run into a little bug where it will respond to the click() request even whi

I'm in the midst of writing a slide show app (click a button, and you slide through a list of images) for jQuery, but I've run into a little bug where it will respond to the click() request even while an animation is happening. I'm using the animate() function already, so that isn't staving off t开发者_JS百科he additional animation requests.

Any way to program around this?


You can check whether the animation is in progress in the click handler:

if ($(this).is(':animated')) return false;

Alternatively, you can use the live or delegate functions to only bind the handler to non-animated elements:

$('something:not(:animated)').live('click', function() { ... });
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号