jQuery method .width() was used to get the width of the generated element as:
html: 
<div class='row-fluid' id='photo-preview'></div>
javascript:
 for(i = 0;i < 4;i++){
    var imageSpan = "<div class='span3' id='span_" + i + "'><img src='" + images[i] +"'></div>"
    $('#photo-preview').append(imageSpan);
    var w = $('#span_' + i).width(); 
    console.log(w);
  }
But it got the incorrect value of width. It was the value of percentage instead of pixel. E.g, w should be 400 (400px) but the js got 80 (80%).
I thought the problem may be because the element was dynamically generated. In the console I can got the right value with .width() when all the elements were loaded.
Any ideas to work around with it?