淡出+清空div,然后放入新内容

时间:2012-05-10 23:14:01

标签: jquery fadeout jquery-effects

什么是淡出div的内容的好方法,但保持div为新内容做好准备?

使用

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

div内容刚刚消失,新内容无法显示

使用

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

div会消失,但任何新内容都不会显示

3 个答案:

答案 0 :(得分:20)

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

答案 1 :(得分:5)

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

在等到div之前等待div消失!

答案 2 :(得分:2)

使用fadeOut的回调:

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