Javascript jQuery动态标记选中的所有复选框
我有以下HTML结构-Javascript jQuery动态标记选中的所有复选框,javascript,jquery,html,Javascript,Jquery,Html,我有以下HTML结构- <div class="first_checkbox"> <input type="checkbox" name="checkbox" class="all-checkbox" value=""> </div> <table> <tr> <td> <input type="checkbox" name="checkbox-32" id="che
<div class="first_checkbox">
<input type="checkbox" name="checkbox" class="all-checkbox" value="">
</div>
<table>
<tr>
<td>
<input type="checkbox" name="checkbox-32" id="checkbox-32" value="" style="opacity: 0;" />
</td>
<td class="h_pincode">380059</td>
<td class="b_add2">Nr. Swatik Cross Road, Navrangpura</td>
</tr>
<tr>
<td>
<input type="checkbox" name="checkbox-34" id="checkbox-34" value="" style="opacity: 0;" />
</td>
<td class="h_pincode">380015</td>
</tr>
</table>
我得到了正确的控制台日志,唯一的区别是,收音机盒没有得到检查
小提琴在这里-检查
JQuery
$("#checkbox-all").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);
});
检查
JQuery
$("#checkbox-all").click(function () {
$('input:checkbox').not(this).prop('checked', this.checked);
});
你的小提琴坏了。您正在匹配一个不存在的all checkbox类,而不是使用checkbox all id属性。辅助复选框的不透明度为零。一旦这些问题得到解决,代码就能正常工作。你的小提琴坏了。您正在匹配一个不存在的all checkbox类,而不是使用checkbox all id属性。辅助复选框的不透明度为零。一旦这些问题得到解决,代码就可以正常工作。