html代码:js代码:function countBodyChildren(){ var body_element=document.getElementsByTagName("body")[0]; alert(body_element.chilNodes.length);}window.onload=countBodyChildren;console中报错:test44.js:9 Uncaught TypeError: Cannot read property 'length' of undefined at countBodyChildren (test44.js:9)countBodyChildren @ test44.js:9
1 回答
撒科打诨
TA贡献1934条经验 获得超2个赞
书写错误吧,是childNodes不是chilNodes
function countBodyChildren(){
var body_element=document.getElementsByTagName("body")[0];
alert(body_element.childNodes.length);
}
window.onload=countBodyChildren;
添加回答
举报
0/150
提交
取消