没有人做过吗?
 那我接着等!
 2、只有当鼠标单击 bb时aa所在行的背景色才恢复正常 同时 bb所在行的背景色变为 red 请问这个该怎么做???

解决方案 »

  1.   

    很多方法<table>
    <tr>
        <td id="first"><a href="#">aa
         </td>
    </tr>
    <tr>
        <td id="secend" onclick="func()">bb
         </td>
    </tr>
    </table>
    function func(){
       document.getElementById("first").bgcolor=....
    }
      

  2.   

    可以有好多方法的,我先试了用样式表和脚本结合的方法,以后有时间再加上别的方法
    <style type="text/css">
    #mytable tr {changeColor:expression(onclick=function(){changeColor(this)})}
    </style>里面的#mytable是你的表格的id,你自己设置一个id给表格#mytable tr这样写表示只对mytable里面的tr标签设置样式然后changecolor(this)函数写在另外的地方,要放在表格的代码的后面
    <script language="javascript">     function changeColor(obj)
    {
     
    for(i=0;i<document.getElementById("mytable").rows.length;i++)
        {
    document.getElementById("mytable").rows[i].style.backgroundColor="#FFFFFF";
    }
    obj.style.backgroundColor="green"

         
     }</script>前面的循环是用来遍历表格的每一行,并设置它的背景为白色,然后obj.style.backgroundColor就是用来设置你当前点击的行的背景颜色,obj由你调用函数的时候输入的参数确定,一定要输入this,代表点击的当前行
      

  3.   

    或者看一下这个朋友的http://community.csdn.net/Expert/topic/4747/4747132.xml?temp=.4019281