批量设置页面上指定按钮不可用和恢复可用

来源:互联网 发布:网络机柜图 编辑:程序博客网 时间:2024/05/20 18:17

 function disableAll(){
 var boxList = document.getElementsByTagName("input");                                                 //获取标签名为input的标签集合
 for(i=0;i<boxList.length;i++){
  if(boxList[i].type=="button" || boxList[i].type=="checkbox" || boxList[i].type=="submit"){   //想要设置不可用的按钮
   boxList[i].disabled="disabled";                                                                                                 //设置不可用
  }
 }
}

 

 

function unlockAll(){
 var boxList = document.getElementsByTagName("input");
 for(i=0;i<boxList.length;i++){
    if(boxList[i].type=="button" || boxList[i].type=="checkbox" || boxList[i].type=="submit"){
   boxList[i].disabled = null;
  }
 }
}