do not use numbers as id, but try<table><tr>
<td width="30" height="30" id=2230>hello;</td>
<td width="30" height="30" id=2330>world</td>
</tr>
</table>
<script>
function setcolor(obj,color)
{
obj.bgColor = color;
}setcolor(document.all('<%=h%>'),'<%=states%>');
</script>
<td width="30" height="30" id=2230>hello;</td>
<td width="30" height="30" id=2330>world</td>
</tr>
</table>
<script>
function setcolor(obj,color)
{
obj.bgColor = color;
}setcolor(document.all('<%=h%>'),'<%=states%>');
</script>
解决方案 »
- 关于js中for循环的一个问题
- 浏览器不提示js错误
- 为什么每次使用this.ownerCt就报告为定义、
- question.
- 怎么用js隐藏body里没有标签的文字?
- 问下大家,JS中又没有办法获取当前正在编辑的元素
- 新手事件代码是不是这样一来的形式?
- 求助帮我改一下JS 在线等待 谢谢
- 非常讨厌的3721令我烦感!请大家帮助!
- 脚本定界符 <% 和 %> 、HTML 标记 <SCRIPT> 和 </SCRIPT> 或 HTML 标记 的区别
- 如何解密被加密了的JS脚本?
- 我的单元格内有一个CheckBox,单元格要比CheckBox大的多,如何实现我点击CheckBox所在的单元格就可以将CheckBox选中?
但是运行的时候它提示说:null不是对象
那2个td设了颜色,但不是传递过去的那个颜色,是黑色!
2. and if possible, put the code in onload event handler, like this:<% h="t2230"
states = "red"
%>
<body onload="
setcolor(document.all('<%=h%>'),'<%=states%>');">
<table><tr>
<td width="30" height="30" id=t2230>hello;</td>
<td width="30" height="30" id=t2330>world</td>
</tr>
</table>
<script>
function setcolor(obj,color)
{
obj.bgColor = color;
}//setcolor(document.all('<%=h%>'),'<%=states%>');
</script>
</body>
但是还是出现"null不是对象"