请教使用javascript脚本写一个table根据鼠标经过,离开,点击时而改变颜色? <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> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以:<table width="100%" border="0" cellspacing="0" cellpadding="0" onclick="this.bgColor='red';"> <tr> <td>我们</td> </tr></table> 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' : '';} //参数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>当点击“我们”时颜色变成绿色,但我点击“你们”时颜色变成红色,而“我们”又恢复。如何写呀!菜菜鸟! 谢谢: kingchang2000(萨那) 你的代码是我要达到的要求!谢谢 window.showModalDialog返回值undifined 如何当浏览者打开一个网页,就自动联系我的qq? Extjs 2.3中的Combobox下拉框中怎么去掉分页 新手问:javascript的几个问题 ●●● 怎样设置Javascript展开菜单的默认效果为打开呢? 如何判断列表框的数据已经存在 关于字符串的问题 window.opener.location.reload();的问题 简易的客户端数据库(大家多交流) 大家进来看看这个是什么问题 在新打开的IE中关闭已知名字的IE窗口,在线等 我怎樣返回?
<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>
当点击“我们”时颜色变成绿色,但我点击“你们”时颜色变成红色,而“我们”又恢复。如何写呀!菜菜鸟!