selecting deselecting all items in checklist

鲍鸿波
2023-12-01
<html xmlns=" http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#<%=chkSelectAll.ClientID %>').click(function () {
                //Use the jQuery selector to retrieve all checkboxes from the CheckBoxList and toggle the 'checked' attribute
                $('#<%=chkList.ClientID %> input:checkbox').attr('checked', $('#<%=chkSelectAll.ClientID %>').is(':checked'));
            })
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:CheckBox ID="chkSelectAll" runat="server" Text="Select All" />
    <asp:CheckBoxList ID="chkList" runat="server">
            <asp:ListItem Value="1" Text="Standard"></asp:ListItem>
            <asp:ListItem Value="2" Text="Silver"></asp:ListItem>
            <asp:ListItem Value="3" Text="Gold"></asp:ListItem>
            <asp:ListItem Value="4" Text="Premier"></asp:ListItem>
        </asp:CheckBoxList>
    </div>
    </form>
</body>
</html>
 类似资料:

相关阅读

相关文章

相关问答