开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜