我想一片相关的控件都变成blue,但是这样错误了,如果把str改成固定的值,就能成功
for(var icount=0 ; icount <= x ; icount++ )
{ var str =(""+icount+","+y+"").toString();
document.getElementById(str).style.background="blue";
}
我的问题什么原因,怎么解决<td width=4pt align="center" onclick="ChangeColor(this)" onmouseover="overtMouse(this)" onmouseout="outMouse(this)" > <FONT style="BACKGROUND-COLOR: green" id='+col+','+row+' >'+" "+' </FONT> </td>
我调用的对象
for(var icount=0 ; icount <= x ; icount++ )
{ var str =(""+icount+","+y+"").toString();
document.getElementById(str).style.background="blue";
}
我的问题什么原因,怎么解决<td width=4pt align="center" onclick="ChangeColor(this)" onmouseover="overtMouse(this)" onmouseout="outMouse(this)" > <FONT style="BACKGROUND-COLOR: green" id='+col+','+row+' >'+" "+' </FONT> </td>
我调用的对象
alert(str);//看看是不是你要的值
alert(str);看看和你的ID是否一样
var str =(""+0+","+y+"")能成功吗?
-------------
test(IE6-OK)<body><table border="1" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width=4pt align="center" onclick="ChangeColor(this)" onmouseover="overtMouse(this)" onmouseout="outMouse(this)" > <FONT style="BACKGROUND-COLOR: green;color:#fff" id=0,1 > </FONT> </td>
<td width=4pt align="center" onclick="ChangeColor(this)" onmouseover="overtMouse(this)" onmouseout="outMouse(this)" > <FONT style="BACKGROUND-COLOR: green;color:#fff" id=1,1 > </FONT> </td>
<td width=4pt align="center" onclick="ChangeColor(this)" onmouseover="overtMouse(this)" onmouseout="outMouse(this)" > <FONT style="BACKGROUND-COLOR: green;color:#fff" id=2,1 > </FONT> </td>
</tr>
</table>
<script language="javascript">
<!--
var x=2,y=1
for(var icount=0 ; icount <= x ; icount++ ) {
var str =(""+icount+","+y+"").toString();
document.getElementById(str).style.background="blue";
}
//-->
</script></body>