How to get the height of a DIV considering inner element's margins?

Posted by André Pena on Stack Overflow See other posts from Stack Overflow or by André Pena
Published on 2010-03-31T17:13:35Z Indexed on 2010/03/31 17:23 UTC
Read the original article Hit count: 235

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about css