Fadeout + clear div and then add new content to

What is a good way to smooth out div content , but so that the div is ready for new content?

FROM

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

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

FROM

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

Div disappears, as it should be, but any new content does not show

+7
source share
3 answers
 $('#info').fadeOut(500, function() { $(this).empty().show(); }); 
+14
source
 $('#info').fadeOut(500, function() { $(this).html('').show(); }); 

Wait until the div disappears before emulating it!

+5
source

Use fadeOut callback:

 $('#info').fadeOut(500, function() { $('#info').html("New Content").show(); }); 
+2
source

All Articles