How do you get an element's inner height, without padding and borders?
No jQuery, just pure JS, and a cross-browser solution (IE7 included)
The innerHeight() method returns the inner height of the FIRST matched element. As the image below illustrates, this method includes padding, but not border and margin. Related methods: width() - Sets or returns the width of an element.
HTML. outerHeight() It returns the current height of the element including the padding, border and margin optionally.
To obtain the height of the window minus its horizontal scroll bar and any borders, use the root <html> element's clientHeight property instead. Both innerHeight and innerWidth are available on any window or any object that behaves like a window, such as a tab or frame.
var style = window.getComputedStyle(document.getElementById("Example"), null); style.getPropertyValue("height");
The above version will work in modern browsers. Please check currentStyle
for IE browsers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With