为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

有只小跳蛙 2019-02-13 15:19:33
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;


查看完整回答
反对 回复 2019-02-26
  • 1 回答
  • 0 关注
  • 514 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号