效果:

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>

标签:
checkbox,全选,全取消

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com