开发者

how to get the height of a element including padding and borders using javascript

开发者 https://www.devze.com 2023-02-09 00:21 出处:网络
i would like to know how to get the height of a element including padding and borders using javascript so ill know the actua开发者_JS百科lly height the element has when rendered in a browser.

i would like to know how to get the height of a element including padding and borders using javascript so ill know the actua开发者_JS百科lly height the element has when rendered in a browser. Can anyone help me please and im still new to javascript


You're looking for element.offsetHeight and element.offsetWidth.

According to quirksmode.com, these properties work in all of the major browsers. Hooray!


Using jQuery, you can get element height including padding with $(ele).outerHeight(), get element height including padding, border and margin by $(ele).outerHeight(true).

see also https://api.jquery.com/outerHeight/

0

精彩评论

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