我有一个问题,我的动画完美无缺,但是当.hide();触发它只是恢复到slideDown();功能
我正在摸不着头脑,虽然我假设它正在运行动画,因为之前的点击仍处于活动状态?
$('div.SocialShareJob').on('click', function(){
$(this).find('p').slideUp(300).fadeOut(500);
$(this).find('.Icons').slideDown(500).fadeIn(900);
});
$('div.CloseSharing').on('click', function(){
$(this).parent('div.Icons').hide();
});
答案 0 :(得分:4)
您需要stop尚未完成的动画,并清除队列:
$('div.CloseSharing').on('click', function(event){
$(this).parent('div.Icons').stop(true).hide();
});
如果closeSharing
div是另一个div的孩子,您可能还需要阻止click
事件传播到父级。为此,请将event.stopPropagation()
添加到事件处理程序的开头:
$('div.CloseSharing').on('click', function(event){
event.stopPropagation();
$(this).parent('div.Icons').stop(true).hide();
});