我有DOM节点和点击处理程序,我需要在动画时禁用该操作.如何检查元素当前是否正在通过jQuery动画进行动画处理?
$('div').on('click','.item',function() { if (/* this not animating */) { animate($(this)); } });
我是否需要在该元素上设置数据(‘play’),这些数据在完成时会更清楚,或者有更好的方法.
解决方法
尝试使用以下内容:
$('div').on('click',function() { $this = $(this); // cached so we don't wrap the same jquery object twice if (!$this.is(':animated')) { animate($this); } });