table checkbox 列全选或全不选

html标签:

<table class="table table-striped table-bordered table-hover" style="border: 1px solid lightgray; table-layout: fixed">
<thead>
<tr>
<th scope="col" style="text-align: center;width: 30px;"><input type="checkbox" class="th_check_all" name="check_box" /></th>
<th scope="col" style="text-align: center; width: 80px;">操作</th>
<th scope="col" style="text-align: center; width: 100px;">计划周期</th>
</tr>

</thead>

<tbody>

<tr>
<td style="text-align: center;">
<input name="ckb" type="checkbox" value ="" />
</td>
<td style="text-align: center;">
已接收
</td>
<td style="text-align: center;"><%=obj.GetValue<string>("planperiodtime","") %></td>

</tr>

</tbody>
</table>

 

JS:

$(".th_check_all").click(function () {

        if ($(this).is(':checked') == true) {

            $("input[name='ckb']").prop("checked", true);

        } else {

            $("input[name='ckb']").prop("checked", false);

        }

    });  

posted @ 2022-03-14 14:15  ebigear  阅读(120)  评论(0)    收藏  举报