我試圖使用JQuery更改以下標籤的css,但我無法弄清楚。這實際上是我的checkboxlist(asp.net)中的html,這是迄今爲止我所擁有的。任何人都可以幫忙嗎?謝謝。更改已選中複選框的標籤css
下面的JQuery查找整個表格,並使所有標籤變成紅色,而不僅僅是我檢查的標籤。
$("#CheckBoxList1").click(function() {
$(this).find('label').removeClass('red');
if ($('span').hasClass('checked'))
$(this).find('label').addClass('red');
});
<table id="CheckBoxList1" border="0">
<tbody>
<tr>
<td>
<div class="checker" id="uniform-CheckBoxList1_0">
<span>
<input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" style="opacity: 0; "/>
</span>
</div>
<label for="CheckBoxList1_0">Mark Park</label>
</td>
<td>
<div class="checker" id="uniform-CheckBoxList1_1">
<span>
<input id="CheckBoxList1_1" type="checkbox" name="CheckBoxList1$1" style="opacity: 0; "/>
</span>
</div>
<label for="CheckBoxList1_1">Amy Lee</label>
</td>
<td/>
</tr>
</tbody>
</table>
這是做到了。謝謝。 – MikeB55