我试图在两个条件下禁用复选框,如果表中或最后一行中只有一行,但它没有得到为什么不禁用。
HTML:
<table id="table_forms">
<tr>
<td><input type="checkbox" class="chkView"/>View</td>
</tr>
<tr>
<td><input type="checkbox" class="chkView"/>View</td>
</tr>
</table>联署材料:
$('#table_forms tr:last input[type="checkbox"]').disabled;发布于 2015-09-09 12:01:16
您可以使用prop()设置禁用属性,也可以使用[0]获取dom元素和设置disabled属性。
$('#table_forms tr:last input[type="checkbox"]').prop('disabled', true);<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id="table_forms">
<tr>
<td>
<input type="checkbox" class="chkView" />View</td>
</tr>
<tr>
<td>
<input type="checkbox" class="chkView" />View</td>
</tr>
</table>
或
$('#table_forms tr:last input[type="checkbox"]')[0].disabled = true;<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table id="table_forms">
<tr>
<td>
<input type="checkbox" class="chkView" />View</td>
</tr>
<tr>
<td>
<input type="checkbox" class="chkView" />View</td>
</tr>
</table>
发布于 2015-09-09 12:05:06
试试这个:
$('#table_forms tr:last input[type="checkbox"]').attr('disabled','disabled');https://stackoverflow.com/questions/32479017
复制相似问题