最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What does the "Uncaught TypeError: Cannot read property" JS error mean? - Stack Overflow

programmeradmin3浏览0评论

Can someone explain to me what these errors mean?

I need the answers for a school project.

Error 1 "Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null"
Error 2 "Uncaught TypeError: Cannot read property 'dom' of null"

Can someone explain to me what these errors mean?

I need the answers for a school project.

Error 1 "Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null"
Error 2 "Uncaught TypeError: Cannot read property 'dom' of null"
Share Improve this question edited Feb 3, 2016 at 20:49 Barett 5,9586 gold badges53 silver badges56 bronze badges asked Oct 22, 2015 at 8:22 JobvdweerdJobvdweerd 611 gold badge1 silver badge3 bronze badges 2
  • 4 You try to read some properties from a variable that is null. Don't you get more information in the messages, like line numbers or file-names? If you are getting them in a browser, all modern browsers have inspectors with good debuggers, try to use them. – Some programmer dude Commented Oct 22, 2015 at 8:26
  • 1 Please post a Minimal, Complete, and Verifiable example – kittikun Commented Oct 22, 2015 at 8:36
Add a ment  | 

1 Answer 1

Reset to default 4

It means you are trying to use a property on something that is null. Make sure you have an object to operate on before trying to use the property. I.e getBoundingClientRect expects a dom element.

One way to select a dom element is by id:

var element = document.getElementById('myElement');

More about selecting dom elements here.

发布评论

评论列表(0)

  1. 暂无评论