<script for=table event=onclick()>
var se = event.srcElement, row;
var lightrow=null; if (se.tagName == "TD") {
if(lightrow!=null){
lightrow.style.color="normalcolor";
lightrow.style.backgroundColor = "normalBgcolor";
}
row = se.parentElement;
row.style.color = "highlighttext";
row.style.backgroundColor = "highlight";
lightrow=row;
}
</script>

解决方案 »

  1.   

    你可以先写个循环,将每个行的style的color和backgroundcolor的属性设为原来的颜色
    然后再调用你自己上面的程序,就可以了吧
      

  2.   

    把这行var lightrow=null;改成window.lightrow=null;应该就行了。
      

  3.   

    没用啊?window有lightrow属性吗?
    实在不行的话,一定要循环的话,应该怎么写啊?
      

  4.   

    <script>
    var lightrow=null;
    </script>
    <script for=table event=onclick()>
    var se = event.srcElement, row; if (se.tagName == "TD") {
    if(lightrow!=null){
    lightrow.style.color="normalcolor";
    lightrow.style.backgroundColor = "normalBgcolor";
    }
    row = se.parentElement;
    row.style.color = "highlighttext";
    row.style.backgroundColor = "highlight";
    lightrow=row;
    }
    </script>
      

  5.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>Untitled Document</title>
    <script language="javascript">
    var curRow; //全局行号
    var curColor;
    function selectRow(tr1){
    if(curRow)
    curRow.bgColor=curColor;
    curColor=tr1.bgColor;
    tr1.bgColor="#FFE9B3";
    curRow=tr1;
    }
    </script>
    </head>
    <body >
    <table id="tb" width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr onClick="selectRow(this)">
        <td valign="bottom" id="tdPic">&nbsp;</td>
        <td valign="bottom" id="tdPic">&nbsp;</td>
        <td valign="bottom" id="tdPic">&nbsp;</td>
      </tr>
      <tr onClick="selectRow(this)">
        <td valign="bottom" id="tdPic">&nbsp;</td>
        <td valign="bottom" id="tdPic">&nbsp;</td>
        <td valign="bottom" id="tdPic">&nbsp;</td>
      </tr>
      <tr onClick="selectRow(this)">
        <td valign="bottom" id="tdPic">&nbsp;</td>
        <td valign="bottom" id="tdPic">&nbsp;</td>
        <td valign="bottom" id="tdPic">&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>