tags:

views:

15

answers:

1

Hi,

I have the following jQuery which will allow me to update the widths and classes from the header of one table onto the data cells of another.

Currently the following only updates the first row in the other table but i need it to update all the widths and classes in the other table for consistency :(

$($orginalHeaders).each(function(index) {
    $headWidth = $(this).attr('width');
    $headClass = $(this).attr('class');        
    $('#quotations').find('tbody tr td:eq(' + index + ')').attr({
        width: $headWidth,
        class: $headClass
    });
});
+1  A: 

Try

$('#quotations tbody tr').each(function(){
    $(this).find('td:eq(' + index + ')').css('width', $headWidth).addClass($headClass);        
});
rahul
I actually went with this: $('#quotations tbody tr').each(function(indexRow) { $($orginalHeaders).each(function(indexCell) { $headWidth = $(this).attr('width'); $headClass = $(this).attr('class'); $this = $(this); $('#quotations').find('tbody tr:eq(' + indexRow + ') td:eq(' + indexCell + ')').attr({ width: $headWidth, class: $headClass }); }); });
RyanP13