获得元素的全高度? [英] Get full height of element?
问题描述
我的博客的内容 div
, id
#content
。当我选择它时,例如使用Firebug,它概述了 div
的全部高度,其顶部和底部的所有填充和边距都是如此。
My blog has a content div
with an id
of #content
. When I select it, e.g. with Firebug it outlines the full height of the div
, with all its padding and margins at the top and the bottom.
jQuery height()
仅返回元素本身的内部高度。
jQuery height()
returns only the inner height of the element itself.
如何查询元素的完整高度?如果其他元素中有大量填充和边距,我希望所有加起来并作为一个值。
How can I query the full height of the element? If there are other elements with a lot padding and margin in them I want all of it added up and as one value.
哪种方法应该我用?
推荐答案
你可以使用 outerWidth
和 outerHeight
在 jQuery> = 1.3之后可用的函数。
$(elemenet).outerHeight()
将返回包含带边框和填充的高度的高度
$(elemenet).outerHeight()
will return height including height with borders and paddings
使用 $ (element).outerHeight(true)
也包括边距。
这篇关于获得元素的全高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!