Last active
November 10, 2015 00:43
-
-
Save jamiehs/696098887a26f2a7ca6c to your computer and use it in GitHub Desktop.
A novel method of finding the height of an absolutely positioned element. From: http://stackoverflow.com/a/20791125
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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