【发布时间】:2020-02-06 03:34:27
【问题描述】:
我有一张这样的桌子。
<table>
<tr class="rowA baris">
<td>A<td>
<Td><input class="checkbox" type="checkbox"><td>
</tr>
<tr class="rowB baris">
<td>B<td>
<Td><input class="checkbox" type="checkbox"><td>
</tr>
</table>
然后,我想要这样的结果 Result
我想要我选中的复选框将 CSS 背景颜色更改为浅灰色的行。 我该怎么做?
目前使用这个 JQuery :
$('.checkbox').click(function () {
if ($(this).is(":checked")) {
$('.baris').attr('style', 'background-color: lightgrey;');
}
});
但所有行都变成浅灰色。
【问题讨论】: