2011-10-26 42 views
3

我得到一个点击多数民众赞成在一个div上触发slideDown()。我的想法是,在div展开后,我根据展开的div设置另一个div的高度。问题在于它需要高度并在其他div完全滑动之前设置它,因为它需要在滑出之前获取div的高度。设置元素滑动后的高度()

有没有办法暂停一切,直到slideDown()完成?

$div.slideDown(); 

//sets the height of the Container 
$outer_container.css("height", $inner_container.outerHeight()); 

回答

3

使用callback function,只运行一次的动画完成:

$div.slideDown(400, function() { 
    //sets the height of the Container 
    $outer_container.css("height", $inner_container.outerHeight()); 
}); 

或者,使用稍微更紧凑apprach:

$div.slideDown(400, function() { 
    $outer_container.height($inner_container.outerHeight()); 
}); 
相关问题