Save the current height:
var curHeight = $('#first').height();
Temporarily switch the height to auto:
$('#first').css('height', 'auto');
Get the auto height:
var autoHeight = $('#first').height();
Switch back to curHeight
and animate to autoHeight
:
$('#first').height(curHeight).animate({height: autoHeight}, 1000);
And together:
var el = $('#first'),
curHeight = el.height(),
autoHeight = el.css('height', 'auto').height();
el.height(curHeight).animate({height: autoHeight}, 1000);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…