zoukankan      html  css  js  c++  java
  • JQuery下CheckBox全选全不选反选

        <script src="JS/jquery-1.7.1.js"></script>
        <script type="text/javascript">
            $(function () {
                $('[value=全选]').click(function () {
                    $(':checkbox').attr("checked", "checked");
                });
                $('[value=全不选]').click(function () {
                    $(':checkbox').removeAttr("checked");
                });
                $('[value=反选]').click(function () {
                    ////1.
                    //$(':checkbox').each(function () {
                    //    $(this).attr("checked", !$(this).attr("checked"));
                    //});
                    //2.
                    // $(':checkbox').each(function () {
                    $(':checkbox').attr("checked", function () {
                        if ($(this).attr("checked"))
                            return false;
                        return true;
                    });
                    // });
                });
            });
        </script>
    </head>
    <body>
        <input type="button" value="全选" />
        <input type="button" value="反选" />
        <input type="button" value="全不选" /><br />
        <input type="checkbox" id="1" /><label for="1">1</label>
        <input type="checkbox" id="2" /><label for="2">2</label>
        <input type="checkbox" id="3" /><label for="3">3</label>
        <input type="checkbox" id="4" /><label for="4">4</label>
        <input type="checkbox" id="5" /><label for="5">5</label>
        <input type="checkbox" id="6" /><label for="6">6</label>
        <input type="checkbox" id="7" /><label for="7">7</label>
        <input type="checkbox" id="8" /><label for="8">8</label>
        <input type="checkbox" id="9" /><label for="9">9</label>
    
    </body
  • 相关阅读:
    datepicker防手动输入
    [ACM]Link-Cut Tree实现动态树初探
    STL priority_queue 优先队列 小记
    hihoCoder挑战赛1 毁灭者问题
    python编程技巧
    openstack horizon 学习(3) DataTable
    Upcasting, downcasting in JAVA
    SGU 145
    URAL 1003,1004
    自建物流的无人机实验(困难)
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/3576178.html
Copyright © 2011-2022 走看看