I am trying to get the height of a div container that does not have the originally set height and contains a floating element. The offsetHeight property continues to grow 0 . I can get the height if I set the div overflow property to hidden . Is there a better way than this?
I have an example in jsFiddle - http://jsfiddle.net/6RQMb/ . This is my first time using jsFiddle for testing, so let me know if I did something wrong ...
In case I messed up something using jsFiddle (and because he requested it for stackoverflow), here is an example of information:
HTML
<div id="container"><p>Some text that gives this element height</p></div>
CSS
p {float:left;}
JAVASCRIPT
alert( document.getElementById('container').offsetHeight );
source share