Reputation: 716
I have a div called .A
coded as height:auto
that has a height rendered based on the text contained within. I have another div on the page called .B
that I need to animate down using jQuery based on the height of the first div, .A
.
I have attempted using the following jQuery function, without much luck. The idea was to have jQuery ascertain the height of .B
then apply a padding to .B
, however it is not grabbing the correct height. I have also tried using 'marginTop'
jQuery('div.A').animate({'paddingTop': jQuery('div.B').height()},500);
Desparate for help! Will pay with up-votes and generous compliments.
Upvotes: 0
Views: 144
Reputation: 74738
I think you need .outerHeight(true)
:
jQuery('div.A').animate({ paddingTop : jQuery('div.B').outerHeight(true)},500);
.outerHeight()
from docsGet the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements.
Note:
The top and bottom padding and border are always included in the .outerHeight() calculation; if the includeMargin argument is set to true, the margin (top and bottom) is also included.
Upvotes: 1