cant calculate width of elements
- by Kein
I try to get width of dom objects:
function resizeArea(){
var width = 0;
area.children().each(function(i){
alert(this.offsetWidth);
width += this.offsetWidth;
});
area.css('width', width);
}
In get results:
Chrome: 800
Opera: 708
FF: 783
IE: 714
But if see it in firebug, dragonfly and other debuggers i see correct 908px.
I don't know where porblem. I run this fun after domloaded.
Here is HTML and css of block:
<div class="scroll_area" id="scroll">
<div class="area" id="area">
<div class="category">
[..]
</div>
</div>
</div>
<style>
#scroll {
position:realtive; width: 800px, heght: 400px;
}
#area {
position:absolute; left: 0; top: 0;
}
#area .category, #area .category .text, #area .category .image{
width: 200px
}
</style>
And that interesting. This function later work correctly, only at first run, for first calculating.