getElementById() returns null even though the element exists [duplicate]

You have to put this in a document load event. The DOM hasn’t gotten to abc by the time the script is executed.

Leave a Comment