我有以下 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
});
});
最佳答案
尝试
$('#quotations tbody tr').each(function(){
$(this).find('td:eq(' + index + ')').css('width', $headWidth).addClass($headClass);
});
关于jQuery 将一个表的标题的属性复制到另一个表中的所有表数据单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3932398/