<script>
function cs()
{
this.className="style1";
}
function cs1()
{
this.className="style2";
}
</script>
....
<td onmouseover="cs()" onmouseout="cs1()">
....
function cs()
{
this.className="style1";
}
function cs1()
{
this.className="style2";
}
</script>
....
<td onmouseover="cs()" onmouseout="cs1()">
....
<table>
<tr style="color:red;" onmouseover="this.style.color='blue';">
<td > 我们</td>
</tr>
</table>
不会啊!
this.style.backgroundColor="#000000"
this.setAttribute("bgcolor","#111111",0);
通过td的style属性改变背景衍射
this.style.backgroundColor="#000000";
id.style.color = "red";
这样是可行的,
因为id是唯一的,
<table id=otable1>
<tr id=otr1>
<td id=otd1_1>..</td>
<td id=otd1_2>...</td>
</tr>
</table>
如果你想用鼠标点一行就变色,那就只设置TR的id,并在TR里加上脚本onclick="fnFocus(this.id)
脚本
<script>
var oldTR=null;
function fnFocus(obj){
if (oldTR != null)
{oldTR.style.backgroundColor='#FFFFFF';
oldTR.style.color="#000000";}
if ( obj)
{
obj.style.backgroundColor="#000066";
obj.style.color="#FFFFFF";
oldTR=obj;
}
}
</script>
<HEAD>
<TITLE> New Document </TITLE>
<style>
.s1 {
background:#FFFFFF;
color:#FF0000;
}
.s2 {
background:#FF0000;
color:#FFFFFF;
}
</style>
</HEAD><BODY>
<TABLE>
<TR>
<TD onClick="this.className='s2'">111111</TD>
<TD style="background:#339900" onClick="this.style.cssText='';this.className='s2'">222222</TD>
</TR>
</TABLE>
</BODY>
</HTML>
.red{background-color:red}
</STYLE>
<table border=1 width=500>
<tr>
<td style="background-color:green" onMouseOver="this.bgColor='red'">this.bgColor='red'</td>
<td style="background-color:green" onMouseOver="this.className='red'">this.className='red'</td>
<td style="background-color:green" onMouseOver="this.style.backgroundColor='red'">this.style.backgroundColor='red'</td>
</tr>
</table>