<input type=checkbox name=t1>
<input type=checkbox name=t1>
<input type=radio name=t1>
<input type=radio name=t1>
<input type=radio name=t1><input type=button value=change onclick="document.body.disabled=true;">

解决方案 »

  1.   


    使所有文本框变灰色
    for(var i=0;i<document.all.length;i++)
    {
      if(document.all[i].type == "text")
      {
        document.all[i].disabled = true;
      }
    }
    //使所有checkbox变灰色
    for(var i=0;i<document.all.length;i++)
    {
      if(document.all[i].type == "checkbox")
      {
        document.all[i].disabled = true;
      }
    }
      

  2.   

    Html中可以自定义一个属性:greyNow = "yes",
    你要是想把某些控件弄灰,可以定义一个这样的属性
    然后在函数中得到所有的elements,一个一个去检查该属性,
    如果该属性为yes,那么就变灰,否则,什么也不做,这个估计更适合你吧