码迷,mamicode.com
首页 > Web开发 > 详细

js实现CheckBox全选全不选

时间:2014-11-19 12:30:27      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   sp   on   2014   log   

 

CheckBox全选全不选的js方法

效果:

 bubuko.com,布布扣bubuko.com,布布扣

页面 :<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);
});
}
}

 

js实现CheckBox全选全不选

标签:style   blog   http   io   color   sp   on   2014   log   

原文地址:http://www.cnblogs.com/lk516924/p/4107849.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!