fadeOut() and slideUp() at the same time?

后端 未结 6 992
难免孤独
难免孤独 2020-12-02 13:05

I have found jQuery: FadeOut then SlideUp and it\'s good, but it\'s not the one.

How can I fadeOut() and slideUp() at the same time? I trie

6条回答
  •  天命终不由人
    2020-12-02 13:18

    The accepted answer by "Nick Craver" is definitely the way to go. The only thing I'd add is that his answer doesn't actually "hide" it, meaning the DOM still sees it as a viable element to display.

    This can be a problem if you have margin's or padding's on the 'slid' element... they will still show. So I just added a callback to the animate() function to actually hide it after animation is complete:

    $("#mySelector").animate({ 
       height: 0, 
       opacity: 0,
       margin: 0,
       padding: 0
    }, 'slow', function(){
       $(this).hide();
    });
    

提交回复
热议问题