简单地说,当我点击一个按钮时,我有一个div动画,当我点击另一个按钮时,它应该是隐藏的:
<div id="popup"></div>
<input type="button" value="show and animate popup" onClick="showWithAnimation()" />
<input type="button" value="hide" onClick="aFunction()" />
<script>
function showWithAnimation(){
console.log('animation called');
$('#popup') .animate({top:(($(window).height()/2)-($('#popup').outerHeight()/2))-70}, 1000, 'easeOutBounce');
$('#popup').show();
}
function aFunction(){//Hide the div
$('#popup').hide();
}
</script>
我注意到的是,反弹效果div仅在我第一次单击时应用show and animate popup,然后当我单击hide按钮然后再次单击show and animate popup按钮时,div会显示,但没有easeOutBounce效果。我可以问你如何去解决这个问题吗?提前谢谢。