tags:

views:

28

answers:

3

Hi,

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

+1  A: 

Use height() method instead:

 $('#element').height();
Sarfraz
A: 

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().

Matthew Manela
A: 
$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document