晕了 自己想出来了 
差了一个a=x;加上后2者是一样的 晕 <script> 
var a;
function test(x){
x.disabled=true;
try {
a.disabled = false;
a=x;
}catch(e){
a=x
}

}
</script> 
<input type="button" id="button1" value="button1" onclick="test(this);"> 
<input type="button" id="button2" value="button2" onclick="test(this);"> 
<input type="button" id="button3" value="button3" onclick="test(this);"> 
<input type="button" id="button1" value="button4" onclick="test(this);"> 
<input type="button" id="button2" value="button5" onclick="test(this);">

解决方案 »

  1.   

    if(a)a.disabled=false;//如果不加if(a) 下面的a=x将永远得不到执行
    a=x;
    ============================================
    这注释是谁写的?拖出去砍了!
      

  2.   

    区别在第2个如果出错了才执行a=x,第一个不管怎么样都会执行a=x;但一次运行这个函数的时候,因为a为null,所以a.disabled = false;这句代码会出错。
      

  3.   

    var a;
    function test(x)
    {
       x.disabled=true;
       if ( 'undefined'!=typeof(a.disabled))
            a.disabled=false;
       a=x;
    }
      

  4.   

    那条注释是对的 如果不加if(a) 每次都会出现错误并跳出 永远不会执行到a=x
      

  5.   

    1楼理解完全错误。不要自己看完就评论 自己试验下在说去掉if(a)  1的例子按钮只要按下就永远变灰。程序只执行x.disabled=true;不去掉   显示按第1个按钮 变灰 按第2个第1个按钮恢复 第2个变灰  依次类推。这里面主要区别a  x    加if(a)   X代表按下按钮   A指的的前1个按钮
      

  6.   

    下面这样也可以<script> 
    var a,b;
    function test(x){
    x.disabled=true;
    b=x;
    a.disabled=false;//如果不加if(a) 下面的a=x将永远得不到执行
    a=x;
    }
    window.onerror=function(){
    a=b;
    }
    </script> 
    <input type="button" id="button1" value="button1" onclick="test(this);"> 
    <input type="button" id="button2" value="button2" onclick="test(this);"> 
    <input type="button" id="button3" value="button3" onclick="test(this);"> 
    <input type="button" id="button1" value="button4" onclick="test(this);"> 
    <input type="button" id="button2" value="button5" onclick="test(this);">
      

  7.   

    <script> 
    var a,b;
    function test(x){
    x.disabled=true;
    b=x;
    a.disabled=false;//如果不加if(a) 下面的a=x将永远得不到执行
    a=x;
    }
    window.onerror=function(){//不要把onerror函数放到test函数中 会失效
    a=b;
    }
    </script> 
    <input type="button" id="button1" value="button1" onclick="test(this);"> 
    <input type="button" id="button2" value="button2" onclick="test(this);"> 
    <input type="button" id="button3" value="button3" onclick="test(this);"> 
    <input type="button" id="button1" value="button4" onclick="test(this);"> 
    <input type="button" id="button2" value="button5" onclick="test(this);">