还有..就是点击了A,再点击B时,A就变回没点击前的效果

解决方案 »

  1.   

    function ok(nu)
    {
      aa.value = nu;
    }
    第二个问题不明白!
      

  2.   

    你可以用css来实现 定义你要的样式 ,class=变量
      

  3.   

    你可以用css来实现 定义你要的样式 ,class=变量怎样控制CLASS变啊?
    因为一开始我定义了一个,然后我点击时想换一个时不会换啊
      

  4.   

    <style>
    .out{border:0;background:#FFFFFF;}
    .over{border:1 solid #000000;background:#dddddd;}
    </style>
    <table id="abc" width="100" height=60>
    <tr>
    <td onclick="ok(1,this)">a</td>
    <td onclick="ok(2,this)">b</td>
    </tr>
    </table>
    <input type=text name=aa>
    <script language="javascript">
    var ptd
    function ok(num,ctd)
    {
    if(ptd!=null)
    ptd.className="out"
    document.all.aa.value=num;
    ctd.className="over"
    ptd=ctd
    }
    </script>
      

  5.   

    <script>
    function test(str)
    {  var obj = event.srcElement
      while(obj!=null && obj.tagName!="TD")
      {
        obj = obj.parentNode
       }  if(obj==null)
        return;  var parobj = obj.parentNode
      for(var i=0;i<parobj.children.length;i++)
      {
        parobj.children(i).style.backgroundColor="#ffffff";
        parobj.children(i).style.borderWidth ="0"  }
      obj.style.backgroundColor="red"
      obj.style.borderStyle ="solid"
      obj.style.borderWidth ="1"
      obj.style.borderColor ="#ffffff"  
      aa.value=str
    }
    </script><table><tr>
    <td onclick="test('1')">asdfsdf</td>
    <td onclick="test('2')">asdfsdf</td>
    <td onclick="test('3')">bddddddddddddddd</td>
    <td onclick="test('4')">asdfsdf</td>
    <td onclick="test('5')">asdfsdf</td>
    </tr>
    </table>
    <input type=text name=aa>