Javascript Error Null is not an Object

Put the code so it executes after the elements are defined, either with a DOM ready callback or place the source under the elements in the HTML.

document.getElementById() returns null if the element couldn’t be found. Property assignment can only occur on objects. null is not an object (contrary to what typeof says).

Leave a Comment