87,963
社区成员
发帖
与我相关
我的任务
分享
<body>
<table align="center" width="650px" id="iTable">
<thead>
<tr bgcolor="#CCFFFF">
<td>name</td>
<td>value</td>
<td>isColor</td>
</tr>
</thead>
<tbody>
<tr>
<td>admin</td>
<td>0</td>
<td name="isColor"> </td>
</tr>
<tr>
<td>admin</td>
<td>1</td>
<td name="isColor"> </td>
</tr>
<tr>
<td>admin</td>
<td>0</td>
<td name="isColor"> </td>
</tr>
</tbody>
</table>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script>
$(function () {
$('#iTable tbody tr').each(function () {
var _value = $(this).find('td').next().text();
if (parseInt(_value) == 0) {
$(this).find('td[name="isColor"]').css('background-color','blue');
} else {
$(this).find('td[name="isColor"]').css('background-color','red');
}
});
})
</script>
</body>
$("td:contains('1')").next().css("background","red");
$("td:contains('0')").next().css("background","blue");
只能这么做吗?