How to fade out div slowly, update content, and then fade in div slowly, using jQuery?

前端 未结 6 1571
梦如初夏
梦如初夏 2020-12-10 02:52

I have a div I want to fade out, update its content, and then fade back in. So far I have tried:

$(\'#myDivID\').fadeOut(\'slow\', function() {
         


        
6条回答
  •  盖世英雄少女心
    2020-12-10 03:34

    When you use replaceWith the content will be visible that is why there is no smooth transition.

    First hiding the div and then calling fadeIn will give smooth transition.

    $('#myDivID').fadeOut('slow', function() {
        $('#myDivID').replaceWith("");
        $('#myDivID').fadeIn('slow');
    });
    

提交回复
热议问题