我有一个html 显示日志,我想循环整个表突出显示具有不同值的行中的任何相邻单元格.
我试图比较特定行中的任何两个值.我设法做了一些事情,但只有2列.
下面是表结构的html示例代码:
old Name |
New Name |
Old Phone |
New Phone |
Old Age |
New Age |
Alphy |
Alphy |
015 | //should be highlited
016 | //should be highlited
23 | //should be highlited
24 | //should be highlited
Tom |
Tom |
12 |
12 |
65 | //should be highlited
30 | //should be highlited
will |
will |
45 |
45 |
20 |
20 |
我的JavaScript代码:
$("#coa_history_data tbody tr.data-in-table").each(function() {
var $firstCell = $('td:eq(3)', this);
var $thirdCell = $('td:eq(4)', this);
if($firstCell.text() === $thirdCell.text()){
}else{
$firstCell.css('backgroundColor','yellow');
$thirdCell.css('backgroundColor','yellow');
}
});
我想提一些建议,如何处理呢?
|