js实现CheckBox全选全不选
CheckBox全选全不选的js方法
效果:
页面 :<table style="width: 2350px; table-layout: fixed;" border="0" cellpadding="0" cellspacing="1"
bgcolor="b5d6e6" class="data_table">
<tr class="scrollColThead ">
<td width="100" class="tb_h scrollRowThead scrollCR">
<input type="checkbox" name="checkAll" class="selectAll" onclick="chkChange();" />
<a href="#" onclick="Del_more()">多项删除</a>
</td>
<td width="100" class="tb_h scrollRowThead scrollCR">
商品编号
</td>
<td width="120" class="tb_h scrollRowThead scrollCR">
商品名称
</td>
</tr>
<asp:Repeater ID="InStoOrdRep" runat="server">
<ItemTemplate>
<tr>
<td class="tb_d scrollRowThead">
<input type="checkbox" class="cb_box" name="chk_delete" value="<%# Eval("Sto_Id") %>" />
</td>
<td title='<%# Eval("Sto_ComNum")%>' class="tb_d hid_td scrollRowThead ">
<%# Eval("Sto_ComNum")%>
</td>
<td title='<%# Eval("Sto_ComName")%>' class="tb_d hid_td scrollRowThead ">
<%# Eval("Sto_ComName")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
js代码:
//全选
function chkChange() {
if ($(".selectAll").attr("checked")) {
$(".cb_box").each(function () {
$(this).attr("checked", true);
});
} else {
$(".cb_box").each(function () {
$(this).attr("checked", false);
});
}
}