在jQuery中,我如何为元素设置动画然后隐藏它?
$(".btn-disapear").click(function () {
var $this = $(this);
$(this).closest(".panel").animate({
opacity: 0
}, 500).slideUp(400);
});
答案 0 :(得分:1)
使用jQuery' .animate()
回调函数。
$(".btn-disapear").click(function () {
var $this = $(this);
$(this).closest(".panel").animate({
opacity: 0
}, 500, function() {
$(this).hide(); // applies display: none; to the element .panel
});
});
答案 1 :(得分:0)
使用jquerys animate函数的完整参数
$(".btn-disapear").click(function () {
var $this = $(this);
$(this).closest(".panel").animate({
opacity: 0
}, 500, function(){
$(this).hide(); //alt $(this).slideUp(400);
});
});
希望这有帮助