i would like to know how to get the height of a element including padding and borders using javascript so ill know the actually 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/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.