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
  • 相关阅读:
    头像裁剪
    实现视频音频基本功能
    原生js实现淘宝验证滑动条 onmousedown onmousemove onmouseup
    hammer实现手机滑动条
    用hammer实现触摸 pan 方法
    TCP cs通信(接收传输)
    HDU6010 DayLight Saving Light(模拟)
    HDU_6000 Wash!(贪心)
    HDU_5783_DivideTheSequence
    LCS(HDU_5495 循环节)
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/3576178.html
Copyright © 2011-2022 走看看