Thanks alot for the suggestion. It didn't work though. I'm at a loss. Is this a jQuery bug, or am I doing something wrong?
On Nov 25, 3:53 pm, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote: > You could try this: > > jQuery('div.clause').each(function(){ > var width = 0; > var words = jQuery(this).children('div.word'); > for (var i=0;i<words.length;i++) > { > var word = words.eq(i); > var thiswidth = word.width(); > var padding = word.css('padding-left'); > width = width + parseInt(thiswidth) + parseInt(padding); > } > jQuery(this).width(width+30); > }); > > -----Original Message----- > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of thesubtledoctor > Sent: Tuesday, November 25, 2008 10:44 AM > To: jQuery (English) > Subject: [jQuery] scope issues in safari > > I need to calculate the widths of the divs of class 'clause' > dynamically based on the widths of their contents, divs of class > 'word'. The following code works correctly in Firefox: > > jQuery('div.clause').each(function(){ > var width = 0; > jQuery(this).children('div.word').each(function(){ > var thiswidth = jQuery(this).width(); > var padding = jQuery(this).css('padding-left'); > width = width + parseInt(thiswidth) + parseInt(padding); > }); > jQuery(this).width(width+30); > }); > > but in Safari it seems that a) the variable 'width' is calculated by > adding the widths of every div.word, not just those within a given > div.clause, b) 'width' is not local within the outer .each brackets, > so that what would be the total width of the second div.clause but for > issue (a) is added on top of the already calculated width for the > first div.clause. > > So in Firefox the calculated widths are 187px, 268px, and 353px, > whereas in safari they are 2838px, 8544px, and 34206px. > > Can anyone suggest a solution? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery (English)" group. To post to this group, send email to jquery-en@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jquery-en?hl=en -~----------~----~----~----~------~----~------~--~---