Search code examples
jqueryfadeoutjquery-effects

Fadeout + empty a div, and then put new content in


What is a good way to fadeout the content of a div, but keeping the div ready for new content?

With

$('#info').html('').fadeOut(500);
or
$('#info').fadeOut(500).html('').show();

The div content just disappears, and new content does not show

With

 $('#info').fadeOut(500);

The div fades as it should, but any new content does not show


Solution

  • $('#info').fadeOut(500, function() {
       $(this).empty().show();
    });