Tell jQuery to ignore clicks during an animation sequence

依然范特西╮ 提交于 2019-12-06 02:32:51

问题


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 the additional animation requests.

Any way to program around this?


回答1:


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() { ... });


来源:https://stackoverflow.com/questions/2489518/tell-jquery-to-ignore-clicks-during-an-animation-sequence

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!