富贵资源网 Design By www.hznty.com

效果:

JS小功能(checkbox实现全选和全取消)实例代码

JS小功能(checkbox实现全选和全取消)实例代码

代码:
复制代码 代码如下:
<head runat="server">
    <title></title>
    <script type="text/javascript">
        window.onload = function () {
            var ckall = document.getElementById('ck1');
            var ck = document.getElementsByName('name1');
            ckall.onclick = function () {
                for (var i = 0; i < ck.length; i++) {
                    if (ckall.checked == true) {
                        ck[i].checked = true;
                    }
                    else {
                        ck[i].checked = false;
                    }
                }
            }
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <input type="checkbox" id="ck1" />
    全选
    <div id="div1">
        <input type="checkbox" name="name1" />
        <input type="checkbox" name="name1" />
        <input type="checkbox" name="name1" />
        <input type="checkbox" name="name1" />
        <input type="checkbox" name="name1" />
        <input type="checkbox" name="name1" />
    </div>
    </form>
</body>

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com