js 中object.childNodes.length undefined是什么原因呢?

html代码:

https://img1.mukewang.com/5c74e6e600013c5915020469.jpg

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


有只小跳蛙
浏览 488回答 1
1回答

撒科打诨

书写错误吧,是childNodes不是chilNodesfunction countBodyChildren(){    var body_element=document.getElementsByTagName("body")[0];    alert(body_element.childNodes.length);}window.onload=countBodyChildren;
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript