我相信我有一个更清洁,更好的解决方案涉及货柜:
<div id="menu_container">
<div id="menu">
<p>my content</p>
</div>
</div>
我要做的是,我将容器锁定的maxHeight和了minHeight到的当前高度DIV。然后我改变了div的内容。最后,我“释放”容器的最大和最小高度到当前内部div的高度:
$("#menu_container").css("min-height", $("#menu").height());
$("#menu_container").css("max-height", $("#menu").height());
$("#menu").fadeOut(500, function() {
//insert here the response from your ajax call
var newHtml = serverResponse;
$(this).html(newHtml).fadeIn(500, function() {
$("#menu_container").animate({minHeight:($("#menu").height())},500);
$("#menu_container").animate({maxHeight:($("#menu").height())},500);
});
});
您使用哪种方法进行ajax请求? – 2012-02-06 17:44:21
@DanieleB:添加 – Nerian 2012-02-06 17:45:57