关于 form表单中,checkbook(复选框 )进行级联选中或级联取消功能的JavaScript

var CheckBoxObj={
process: function(element){
for(var i=0; i<element.length; i++){
   if(element[i].checked){
  return false;
   }
}
return true;
  },
clickParent: function(parentNode, childNode){
var parentElement = document.getElementById(parentNode);
var childElement = document.getElementsByName(childNode);
if(parentElement.checked){
for(var i=0; i<childElement.length; i++){
childElement[i].checked = true;
}
}else{
for(var i=0; i<childElement.length; i++){
childElement[i].checked = false;
}
}
},
clickChild: function(parentNode, childNode){
var parentElement = document.getElementById(parentNode);
var childElement = document.getElementsByName(childNode);
if(this.process(childElement)){
parentElement.checked = false;
}else{
parentElement.checked = true;
}
   }
    
}

你可能感兴趣的:(JavaScript)