全选(CHECKBOX)

来源:互联网 发布:windows查询监听端口 编辑:程序博客网 时间:2024/05/18 01:47

  function IsCheck(chk)
     {
        var form= document.getElementById("form1");
        for(var i=0 ; i < form.length; i++)
        {
           if ( form.elements[i].type == "checkbox")
           {
              form.elements[i].checked = chk;
           }
        }
     }

在源代码里引用:

<div style=" float:left; margin:10px 0px 0px 20px; text-align:left; line-height:25px; width:100px;">
        <input type="checkbox" id="chk" onclick="IsCheck(this.checked)" />全选
        </div>

原创粉丝点击