admin管理员组文章数量:1335138
In general, in the JavaScript console, if it states:
Uncaught TypeError: Object #<HTMLDocument> has no method 'getElementByID'
what is the typical problem in your code? I'm new to JavaScript and in writing a program, this has repeatedly e up and I'm not sure how to fix the problem or what could even possibly be the problem.
In general, in the JavaScript console, if it states:
Uncaught TypeError: Object #<HTMLDocument> has no method 'getElementByID'
what is the typical problem in your code? I'm new to JavaScript and in writing a program, this has repeatedly e up and I'm not sure how to fix the problem or what could even possibly be the problem.
Share Improve this question edited Apr 29, 2012 at 22:37 Ry-♦ 225k56 gold badges492 silver badges498 bronze badges asked Apr 29, 2012 at 22:29 ecode4ecode4 233 bronze badges 1-
user1248795, if indeed the problem was simply that you had
ID
instead ofId
then you should accept either davin's answer or mine. If it was something else, then you should edit the question to make it clearer that there's a further problem. – Gareth McCaughan Commented May 2, 2012 at 9:30
3 Answers
Reset to default 8getElementById
not getElementByID
Lower case d
. JavaScript is case-sensitive.
The typical problem is that you've typed getElementByID
when you meant getElementById
, probably. Alternatively, if that mistyping happened in transcribing the error message rather than in your original code :-), perhaps you did something that you thought would produce a DOM object but that actually produced null
or undefined
or something; there are lots of ways for that to happen.
The right method name is document.getElementById
.
本文标签: Javascript Console TroubleStack Overflow
版权声明:本文标题:Javascript Console Trouble - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742344133a2457180.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论