Created
July 11, 2012 05:12
-
-
Save k4200/3088139 to your computer and use it in GitHub Desktop.
Calculate height (or width etc.) of a hidden element
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
/** | |
* Based on the following discussion: | |
* http://stackoverflow.com/questions/2345784/jquery-get-height-of-hidden-element-in-jquery | |
* @param jQuery $elem jQuery object | |
*/ | |
function getHeightOfHiddenElem($elem) { | |
$clone = $elem.clone(); | |
$clone.css({'position':'absolute','visibility':'hidden','display':'block'}); | |
$('body').append($clone) | |
var height = $clone.height(); | |
$clone.remove(); | |
return height; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment