我有一个从数据库中填充的表。我有两个条件需要申请
- 将斑马条纹应用于表格(已完成)
- 将行颜色更改为基于红色的 td 值
`
<tr class="alt">
<td class="status"><input type="text" value="One"></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status"><input type="text" value="One"></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status"><input type="text" value="Zero"></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status"><input type="text" value="One"></td>
<td class>Received</td>
</tr>
<tr class="alt">
<td class="status"><input type="text" value="Zero"></td>
<td class>Received</td>
</tr>
`
$(document).ready(function()
{
$("tr.alt:even").css("background-color", "#f0f8ff");
$("tr.alt:odd").css("background-color", "#fcfceb");
});
$(document).ready(function() {
$('.status.val():contains("Zero")').closest('tr.alt').css('background-color', '#cd0000');
});
我想根据输入值更改行颜色
<td class="status"><input type="text" value="One"></td>
将不胜感激。