如果一个元素被animation化,如何findjQuery?
我试图在页面上移动一些元素,在animation发生的时候,我想要将“overflow:hidden”应用到elemnt,并且一旦animation完成,就要“溢出”回到“auto”。
我知道jQuery有一个实用function,它决定了一些元素是否正在animation,但我不能在文档中的任何地方find它
if( $(elem).is(':animated') ) {...} 更多信息 : http : //docs.jquery.com/Selectors/animated
要么:
 $(elem) .css('overflow' ,'hidden') .animate({/*options*/}, function(){ // Callback function $(this).css('overflow', 'auto'); }; 
另外,为了testing某些东西是不是animation的,你可以简单的添加一个“!”:
 if (!$(element).is(':animated')) {...} 
 如果你想将css应用到animation元素上,你可以使用:animated伪select器,像这样做, 
 $("selector").css('overflow','hidden'); $("selector:animated").css('overflow','auto'); 
来源: https : //learn.jquery.com/using-jquery-core/selecting-elements/
 $('selector').click(function() { if ($(':animated').length) { return false; } $("html, body").scrollTop(0); }); 
 如果你正在使用cssanimation,并使用特定的class name来分配animation,那么你可以像这样检查它: 
 if($("#elem").hasClass("your_animation_class_name")) {} 
但是在animation完成之后,请确保您正在删除正在处理animation的类名!
 这段代码可以用来在animation结束后删除class name : 
 $("#elem").on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ $(this).removeClass("your_animation_class_name"); });