在做此编程题的过程中有三个问题不理解
1:这里的<script></script>标签是写在<head></head>里面的。按照之前的知识在这里“添加一行”这个函数里面通过getElementById()这个方法应该没用呀,因为这个发生在body里面的内容加载之前。据我所知将javascript代码放在window.onload()=function(){}里面这个问题可以解决。但是我看其他同学的这个函数并没有放在window.onload()=function(){}里面为什么也能够执行成功。
2:
for(var i = 1; i < trs.length; i++) {
trs[i].onmouseover = function() {
this.style.backgroundColor = "gray"; //为什么用this有效果 用trs[i]却没效果
}
trs[i].onmouseout = function() {
this.style.backgroundColor = "white";
}
}
3:td.innerHtml与td.firstChild.nodeValue不都是代表<td></td>中间的文本内容吗?
我用 td.innerHtml=prompt("请输入学号");有效果
用 td.firstChild.nodeValue=prompt("请输入学号");却没有效果
难道前者既能读也可以写,后者只能读不能写?