[jQuery] IE7 returning 0 for attr("width") on an img with width set
Hi All, I have the following code:
$('#slides img').each(function(i){//calculate margins and wrap
var this_img = $(this);
var imgMargin = Math.round((550 - (this_img.attr("width") + 35))/2)
+ 5;
this_img.wrap('<div class="wrap0" style="margin-left:' + imgMargin +
'px"><div class="wrap1"><div class="wrap2"><div class="wrap3"></div></
div></div></div>');
$('#content').append(''+imgMargin+'
');
});
On this page: http://www.colleenkiely.com/testLayout2003-2006.htm
In Firefox and Safari the margin is correctly set. In IE7, the margin
is calculated as if this_img.attr("width") were 0. The html markup has
the height and width of each img set explicitly:
<img src="http://www.colleenkiely.com/site_images/2.jpg" height="510"
width="507" alt="Dog with Egg Hat (#2)" />
I am using the latest JQuery - 1.3.2.
Any insight into this mystery sincerely appreciated.