<script>
function aa(b)
{
o=event.srcElement
if(o.tagName=="TBODY" || o.tagName=="TABLE") return
while(o.tagName!="TR")
o=o.parentElement
for(i=0;i<b.rows.length;i++)
b.rows[i].bgColor="white"
o.bgColor="blue"
}</script>
<table onclick="aa(this)">
<tr><td>aa</td></tr><tr><td>aa</td></tr><tr><td>aa</td></tr><tr><td>aa</td></tr><tr><td>aa</td></tr><tr><td>aa</td></tr>
</table>

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>highLight</title>
    <style>
    td{ font-family: Courier New; font-size: 12px; text-align: center ;height:30;word-break:break-all;}
    </style>
    </head><body>
    <script>         
    var h=null
    function highLight(){
    var e=event.srcElement;
    if(e.tagName!="TD")return;
    e=e.parentElement
    if(!h)h=e;
    h.style.backgroundColor='';
    h=e;
    h.style.backgroundColor='#3366cc'
    }
    function over(){
    var e=event.srcElement;
    if(e.tagName!="TD"||e.parentElement==h)return;
    e=e.parentElement
    e.style.backgroundColor='#d2e8ff'
    }
    function out(){
    var e=event.srcElement;
    if(e.tagName!="TD"||e.parentElement==h)return;
    e=e.parentElement
    e.style.backgroundColor=''
    }
    </script>
    <div align="center">
      <center>
      <table onclick="highLight()" onmouseover="over()" onmouseout="out()" border="1" width="300" bordercolor="#000000" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
        <tr>
          <td width="33%">1</td>
          <td width="33%">saucer</td>
          <td width="34%">100</td>
        </tr>
        <tr>
          <td width="33%">2</td>
          <td width="33%">net_lover</td>
          <td width="34%">99</td>
        </tr>
        <tr>
          <td width="33%">3</td>
          <td width="33%">masterz</td>
          <td width="34%">98</td>
        </tr>
        <tr>
          <td width="33%">4</td>
          <td width="33%">meizz</td>
          <td width="34%">97</td>
        </tr>
        <tr>
          <td width="33%">5</td>
          <td width="33%">pendai</td>
          <td width="34%">96</td>
        </tr>
      </table>
      </center>
    </div></body></html>
      

  2.   

    <script>
    var curr;
    function changecolor(){
    if(curr!=null)
    document.all.table1.rows.item(curr).bgColor = "white";
    curr = event.srcElement.parentElement.rowIndex
    document.all.table1.rows.item(curr).bgColor = "blue";
    }
    </script>
    <table id=table1 border=1 onclick=changecolor()>
    <tr><td>This is Line 1</td></tr>
    <tr><td>This is Line 2</td></tr>
    <tr><td>This is Line 3</td></tr>
    <tr><td>This is Line 4</td></tr>
    </table>