yeah, .width() gets or sets the computed width so in your case, grabbing the attribute makes more sense for your situation
On Mar 25, 1:38 pm, nabrown78 <nabrow...@gmail.com> wrote: > But for that you have to wait until all the images have actually > loaded. I thought it would be faster to get the attribute. Is that > wrong? > > On Mar 25, 11:39 am, MorningZ <morni...@gmail.com> wrote: > > > Use > > > this_img.width() > > > instead > > >http://docs.jquery.com/CSS/width > > > On Mar 25, 11:47 am, nabrown78 <nabrow...@gmail.com> wrote: > > > > 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('<p>'+imgMargin+'</p>'); > > > }); > > > > 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.