2010-10-14 54 views
0

我有以下jQuery,它允许我将一个表头中的宽度和类更新到另一个表的数据单元格中。jQuery将一个表头的属性复制到另一个表中的所有表数据单元格

目前是以下只更新第一行中的其他表,但我需要它来更新其他表中的所有宽度和类一致性:(

$($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

尝试

$('#quotations tbody tr').each(function(){ 
    $(this).find('td:eq(' + index + ')').css('width', $headWidth).addClass($headClass);   
}); 
+0

我('#quotations tbody tr')。each(function(indexRow){($ orginalHeaders).each(function(indexCell){headWidth = $(this).attr('width' ); $ headClass = $(this).attr('class'); $ this = $(this); ('#indexRow +')td:eq('+ indexCell +')')。attr({ width:$ headWidth, class:$ headClass }); }); }); – RyanP13 2010-10-14 11:17:25

相关问题