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?

Reply via email to