You can know the height of an element by duplicating it, setting its height to βautoβ and asking what its height is in pixels.
Say it's the div you want to animate onto: <div id="mydiv" style="height:0px">
, use this code to find out its height (just for jQuery simplicity):
var divHeight = $("#mydiv").clone().css("height", "auto").height();
source share