我正在尝试调整容器 div 的高度增长或手风琴折叠时的高度。折叠工作但在收缩时不调整导致手风琴覆盖 div。有没有更简单的方法来自动调整容器高度?
<script type="text/javascript">
$(document).ready(function(){
$(".acc_body").hide();
$(".acc_head").click(function(){
$(this).toggleClass("acc_head2").next(".acc_body").slideToggle(150);
});
$("div.mainBkgd").click(function(){
var $this = $(this);
if ($this.height() == 930) {
// set height to auto in order to check how tall it is in current window size
$this.css("height","auto");
var height = $this.height();
// done checking height, set back to 30
$this.css("height","930px");
$this.animate({height: height + "px"},1500, function() {
// animation done, set height to auto to allow resizing with window resize
$this.css("height","auto");
});
}
else {
$this.animate({height: "930px"},1500);
}
});
});
</script>