Javascript Console Trouble - Stack Overflow

In general, in the JavaScript console, if it states:Uncaught TypeError: Object #<HTMLDocument> ha

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 of Id 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
Add a ment  | 

3 Answers 3

Reset to default 8

getElementById 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742344133a4426204.html

相关推荐

  • Javascript Console Trouble - Stack Overflow

    In general, in the JavaScript console, if it states:Uncaught TypeError: Object #<HTMLDocument> ha

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信