初学Javascript遇到的一个头痛问题
求大神解答下面红色的错误<!DOCTYPE html>
<html xmlns="http://www.
<head>
<title></title>
<script type="text/javascript">
function gel(id)
{
return document.getElementById(id);
}
window.onload = function ()
{
var tds1 = gel("tbList").childNodes[0].childNodes[0].childNodes; //错误SCRIPT5007: 无法获取未定义或 null 引用的属性“childNodes”
for (var k = 0; k < tds1.length; k++)
{
tds1[k].onclick = checkRed;
}
function checkRed()
{
var tds = gel("tbList").childNodes[0].childNodes[0].childNodes;
var srcE = window.event.srcElemt;
for (var i = 0; i < tds.length; i++)
{
if (tds[i] == srcE)
{
for (var j = 0; j < i; j++)
{
td[j].style.backgroundColor = "red";
}
}
else
{
tds[j].style.backgroundColor = "white";
}
}
}
}
</script>
</head>
<body>
<input type="text" name="textName" value=""/>
<input type="text" name="textName" value=""/>
<input type="text" name="textName" value=""/>
<table id="tbList">
<tbody>
<tr>
<td>
1
</td>
<td>
2
</td>
<td>
3
</td>
<td>
4
</td>
</tr>
</tbody>
</table>
</body>
</html>