<table width="100%" border="0" cellspacing="0" cellpadding="0" onmouseover="this.bgColor='blue';" onmouseout="this.bgColor='';" onclick="this.bgColor='red';">
<tr>
<td>我们</td>
</tr>
</table>
<tr>
<td>我们</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" onclick="this.bgColor='red';">
<tr>
<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' : '';
} //参数t是table的id
至于是鼠标进入,离开,还是点击,那是事件,各个都去调用一下,呵呵,应该不会错。
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td onmouseDown="this.bgColor='red';" onmouseover="this.bgColor='blue';" onclick="this.bgColor='red';">我们</td>
</tr>
<tr>
<td onMouseDown="this.bgColor='red'" onmouseover="this.bgColor='blue';" onclick="this.bgColor='red';">你们</td>
</tr>
</table>
当点击“我们”时颜色变成绿色,但我点击“你们”时颜色变成红色,而“我们”又恢复。如何写呀!菜菜鸟!