我想根据表中的td单元格值将类应用于tr.
我的HTML
<table class="k-focusable">
<tr>
<th>Name</th>
<th>Favorite color</th>
<th> status</th>
</tr>
<td>James</td>
<td>red</td>
<td>false</td>
</tr>
<tr>
<td>John</td>
<td>blue</td>
<td>true</td>
</tr>
</table>
var cellIndexMapping = { 2: true };
$("table.k-focusable tbody tr").each(function (rowIndex) {
$(this).find("td").each(function (cellIndex) {
if (x[cellIndex]) {
var c = $(this).text();
if (($.trim(c) == "false") || ($.trim(c) == "null")) {
$("table.k-focusable tbody tr").find("td").addClass("hover");
}
}
});
});
.hover
{
font-weight:bold
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时,每一行都有这个类悬停.但我希望只有在td值为false或null时才添加该类.
| 归档时间: |
|
| 查看次数: |
120 次 |
| 最近记录: |