What are the possible reasons for document.getElementById
, $("#id")
or any other DOM method / jQuery selector not finding the elements?
Example problems include:
.val()
, .html()
, .text()
) returning undefined
null
resulting in any of several errors:Uncaught TypeError: Cannot set property '...' of null Uncaught TypeError: Cannot read property '...' of null
The most common forms are:
Uncaught TypeError: Cannot set property 'onclick' of null
Uncaught TypeError: Cannot read property 'addEventListener' of null
Uncaught TypeError: Cannot read property 'style' of null