<td width="50%" onMouseover="changecolor(this)" onMouseout="changeback(this)" style="cursor:hand">

解决方案 »

  1.   

    <script>
    function changecolor(obj) {
    obj.style.color="white";
    obj.parentElement.parentElement.parentElement.parentElement.parentElement.style.backgroundColor = "#9999cc";
    }function changeback(obj) {
    status = "";
    obj.style.color="black";
    obj.parentElement.parentElement.parentElement.parentElement.parentElement.backgroundColor = "#D3D3D3";
    }
    </script>
      

  2.   

    如果加上css是不是就不行了呢?看下面的代码
    <html><head>
    <style type="text/css">
    .TableHead{  background-color: #D3D3D3;text-align: center;font-family: Arial;font-size: 12px}
    </style>
    <script>
    function changecolor(obj) {
    obj.style.color="white";
    obj.parentElement.parentElement.parentElement.parentElement.style.backgroundColor = "#9999cc";
    } function changeback(obj) {
    status = "";
    obj.style.color="black";
    obj.parentElement.parentElement.parentElement.parentElement.style.backgroundColor = "#D3D3D3";
    }
    </script>
    </head><body><table border="1" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
      <tr>
        <td width="50%" class="TableHead">
    <table>
    <tr>
    <td class="TableHead">
    </td>
    <td align="center" class="TableHead" onMouseover="changecolor(this)" onMouseout="changeback(this)" style="cursor:hand">
    asdfasf
    </td>
    <td width="1%" align=right class="TableHead">
    </td>
    </tr>
    </table>
    </td>    
    <td width="50%"> </td>
      </tr>
      <tr>
        <td width="50%"> </td>
        <td width="50%"> </td>
      </tr>
    </table></body></html>
      

  3.   

    用ID就可以了
    <script>
    function changeback() {
    aaa.style.color="#11111";
    }
    </script>
    <table>
    <tr>
    <td id="aaa" onMouseover="changeback()" >aaaaa</td>
    </tr>
    </table>