How to get the height of a DIV considering inner element's margins?
- by André Pena
Consider de following markup:
<div id="outerElement">
<div id="innerElement" style="border: 1px solid blue; background-color: #f0f3f5; margin-top: 100px">
TESTE
</div>
</div>
I want to get the actual final height of outerElement using javascript. I noticed that if I remove the vertical margins from innerElement I am able to get what I want but I cannot alter styles from within the outerElement.
How do I do this?
Obs:
I already tried height, scrollheight and offsetHeight in all browsers. Chrome gives me the expected value (including inner element's margins) for scrollHeight. All other browsers fail.