Getting total height of an element?
What's the right way to get the total height of a div element? I'm trying this:
element.outerHeight(true);
but when I take a screenshot of my page, and measure the height (in pixels) of the element, it seems to be a few pixels taller 开发者_开发知识库than what element.outerHeight() is reporting. Is there a different way? I'd like to include all padding/margin in my height.
Thanks
If you want to include the padding and border use outerHeight(false), if you want to include padding, border and margin use outerHeight(true) and if you want to include only the height of the element use height().
Use height()
method instead:
$('#element').height();
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
精彩评论