js實現CheckBox全選全不選

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   sp   on   2014   log   

 

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);
});
}
}

 

js實現CheckBox全選全不選

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.