<table border="1">
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
</table>
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
<tr onclick="this.bgColor = 'lightblue';">
<td>test</td>
</tr>
</table>
<tr>
<td>dddd</td>
</tr>
<tr>
<td>dddd</td>
</tr>
<tr>
<td>dddd</td>
</tr>
<tr>
<td>dddd</td>
</tr>
</table>
<script>
function x(obj)
{
o=event.srcElement
if(o==null || o.tagName=="TABLE") return
while(o.tagName!="TR")
o=o.parentElement
if(o.tagName!="TR") return
r = obj.rows
for(i=0;i<r.length;i++)
r[i].bgColor="#FFFFFF"
o.bgColor="red"
}
</script>
function aa()
{
this.bgcolor="#ffffff"
}</script>
<tr><td onclick="parentElement.style.backgroundColor='red'" >第一行</td><td>第一行</td></tr>
<tr><td onclick="parentElement.style.backgroundColor='blue'">第二行</td><td>第二行</td></tr>
</table>
for (var i=0; i<t.rows.length; i++)
for (var j=0; j<t.rows[i].cells.length; j++)
t.rows[i].cells[j].bgColor = t.rows[i].cells[j] == event.srcElement ? 'red' : '';
}
<tr>
<td>dddd</td><td>dddd</td>
</tr>
<tr>
<td>dddd</td><td>dddd</td>
</tr>
<tr>
<td>dddd</td><td>dddd</td>
</tr>
<tr>
<td>dddd</td><td>dddd</td>
</tr>
</table>
<script>
function test(t)
{
for (var i=0; i<t.rows.length; i++)
for (var j=0; j<t.rows[i].cells.length; j++)
t.rows[i].cells[j].bgColor = t.rows[i].cells[j] == event.srcElement ? 'red' : '';
}
</script>楼上的不错哦!