我希望遍历表格并为每个负值的 TD 着色。现在它为整行着色,我可以更改什么来修复它?
jQuery
$('.my-table tr').each(function(index, tr) {
var lines = $('td', tr).map(function(index, td) {
return $(td).text();
});
if( lines[1] < 0 ) {
$(this).css('background-color', 'red');
}
});