Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A novel method of finding the height of an absolutely positioned element. From: http://stackoverflow.com/a/20791125
function absElemHeight(element){
var max_y = 0;
$.each( $(element).find('*'), function(idx, desc){
max_y = Math.max(max_y, $(desc).offset().top + $(desc).height());
});
return max_y - $(element).offset().top;
}
function absElemHeight(element){
$element = $(element);
if($element.find('.inner').length === 0) {
$element.wrapInner('<div class="inner"></div>');
}
return $element.find('.inner')[0].scrollHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.