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

mowgli picture mowgli · May 11, 2012 · Viewed 7.7k times · Source

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

Answer

Hadi Mostafapour picture Hadi Mostafapour · May 11, 2012
$('#info').fadeOut(500, function() {
   $(this).empty().show();
});