我有一个交互式网格,其中一列 ID 设置为
DaysIn
,并且我已将静态 ID 设置为 di
。
我想根据
DaysIn
中的数字值更改背景行颜色。
我已将以下代码添加到刷新后的动态操作中 - 但它不起作用。
$('td[headers="di"]').each(function() {
if ($(this).text() < '30') {
$(this).closest('tr').find('td').css({
"background-color": "beige"
});
}
if ($(this).text() >= '30' && $(this).text() < '60') {
$(this).closest('tr').find('td').css({
"background-color": "lightgreen"
});
}
if ($(this).text() >= '60' && $(this).text() < '65') {
$(this).closest('tr').find('td').css({
"background-color": "lightblue"
});
}
if ($(this).text() >= '65') {
$(this).closest('tr').find('td').css({
"background-color": "pink"
});
}
});
感谢您的帮助。