请教各位大侠:js一个让人想死也想不出来的问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script type="text/javascript">
function initEvent() {
var tableRating=document.getElementById("tableRating");
var tds=tableRating.getElementsByTagName("td");
for(var i=0;i<=tds;i++)
{
var td= tds[i];
td.onclick=TdOnclick;
td.style.cursor="pointer";
}
}
function TdOnclick() {
this.style.background:"red";
}
</script>
</head>
<body onload="initEvent() ">
<table id="tableRating">
<tr><td>*</td><td>*</td><td>*</td><td>*</td><td>*</td></tr>
</table>
</body>
</html>
为什么总是提醒错误:Microsoft JScript 运行时错误: 属性“demo”的值为 null、未定义或不是 Function 对象
------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<script type="text/javascript">
function initEvent() {
var tableRating=document.getElementById("tableRating");
var tds=tableRating.getElementsByTagName("td");
for(var i=0;i<tds.length;i++)
{
var td= tds[i];
td.onclick=TdOnclick;
td.style.cursor="pointer";
}
}
function TdOnclick() {
this.style.background="red";
}
</script>
</head>
<body onload="initEvent() ">
<table id="tableRating">
<tr><td>*</td><td>*</td><td>*</td><td>*</td><td>*</td></tr>
</table>
</body>
</html>