单击一个CheckBox时选中所有子CheckBox

来源:互联网 发布:js高分子防水涂料 编辑:程序博客网 时间:2024/05/16 14:08
 function SelectAll(tempControl) 
 {
    var theBox=tempControl;
    xState=theBox.checked;
    elem=theBox.form.elements;
    for(i=0;i<elem.length;i++)
    {
      if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
      {
        if(elem[i].checked!=xState)
        {
          elem[i].click();
        }
      }
    }
 }
调用:onclick="javascript:SelectAll(this);"
原创粉丝点击