I need element width before appending to body.
Following scripts is working fine in firefox but not in google chrome
<style>
 .testDiv { width:150px; height:100px; }
</style>
<script>
    var div = "<div class='testDiv'>Div Content</div>";
    alert($(div).width());
</script>
It gives output 150 in firefox and 0 in chrome 
I have tried also
$(window).load(
   function() {
    alert($(div).width());
   }
); 
But it is working same...
UPDATE:
I can see, if I declare css inline it works but it is needed to me using css class
var div = "<div style='width:150px;'>Div Content </div>";
alert($(div).width());