zoukankan      html  css  js  c++  java
  • js实现CheckBox全选全不选

    CheckBox全选全不选的js方法

    效果:

     

    页面 :<table style=" 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);
    });
    }
    }

  • 相关阅读:
    Objective-C中的封装、继承、多态、分类
    C语言知识总结(5)
    C语言知识总结(4)
    C语言知识总结(3)
    C语言知识总结(2)
    C语言知识总结(1)
    H5-定位
    H5——浮动及清浮动
    H5基础标签
    H5盒模型基础
  • 原文地址:https://www.cnblogs.com/lk516924/p/4107849.html
Copyright © 2011-2022 走看看