<table border="1" width="100" height="100">
  <tr>
    <td width="100%" onmouseover="bgColor='red'" onmouseout="bgColor=''">test</td>
  </tr>
</table>
TDobj.style.backgroundColor='red'
TDobj.bgColor='red'

解决方案 »

  1.   

    <table border="1" width="100" height="100">
      <tr>
        <td width="100%" onclick="this.style.background='url(csdn.gif)'">test</td>
      </tr>
    </table>
      

  2.   

    <table id="tbl"><tr><td>1<td>2</tr>
    <tr><td>A<td>B</tr></table>
    <input type="button" value="change" onclick="c(0,1,'#0000ff')">
    <script>
    function c(row,col,color){
    tbl.rows[row].cells[col].bgColor=color;
    }
    </script>
      

  3.   

    首先谢谢fason大虾的帮助,我首先的问题不太准确,我想通过点击一行中的某个单元格,来控制这行和另外一行的背景的交换,请问有没有办法?谢谢,谢谢!
      

  4.   

    这里应该是你的答案了
    http://expert.csdn.net/Expert/topic/1948/1948456.xml?temp=.9247248
      

  5.   

    可是这些方法好像在netscape中不支持呀!请大虾们继续支持!
      

  6.   

    <script>
    var h=null
    function oLight(e){
    if(!h)h=e;
    h.style.backgroundColor=''
    h=e;
    h.style.backgroundColor='red'
    }
    </script>
    <table border="1" width="100" >
      <tr onclick="oLight(this)">
        <td width="100%"> </td>
      </tr>
      <tr onclick="oLight(this)">
        <td width="100%"> </td>
      </tr>
      <tr onclick="oLight(this)">
        <td width="100%"> </td>
      </tr>
      <tr>
        <td width="100%"> </td>
      </tr>
    </table>
      

  7.   

    不知道是不是这样?
    <script>
    function oLight(e,flag){
    e=e.parentNode.parentNode;
    r=document.getElementById('test').rows[e.rowIndex+flag]
    temp=e.style.backgroundColor
    e.style.backgroundColor=r.style.backgroundColor
    r.style.backgroundColor=temp
    }
    </script>
    <table border="1" width="100" id=test>
      <tr style="background-color:red">
        <td width="100%"><input type=button value="down" onclick="oLight(this,1)"></td>
      </tr>
      <tr>
        <td width="100%"><input type=button value="up" onclick="oLight(this,-1)"><input type=button value="down" onclick="oLight(this,1)"> </td>
      </tr>
      <tr>
        <td width="100%"><input type=button value=up onclick="oLight(this,-1)"><input type=button value=down onclick="oLight(this,1)"> </td>
      </tr>
      <tr>
        <td width="100%"><input type=button value=up onclick="oLight(this,-1)"> </td>
      </tr>
    </table>
    将按钮换为图片
      

  8.   

    真牛X!!!!!在IE里很爽,在netscape里的效果还没有完全出来!点击后,交换的白颜色没有了,全部变成红的了!有请大虾再试试!太谢谢了!
      

  9.   

    我的是ns6,我们给客户的需求明确了是用ns6,我没法去跟他们说了,大虾救人救到底,假如是ns6,您有没有办法呢?