Uncaught Typeerror: cannot read property 'innerHTML' of null

前端 未结 8 2225
遥遥无期
遥遥无期 2020-12-05 12:04

Can anyone explain what is theses errors?

Uncaught TypeError: cannot read property \'innerHTML\' of null

View on my website This

8条回答
  •  萌比男神i
    2020-12-05 13:00

    Update:

    The question doesn't ask for jquery. So lets do it without jquery:

    document.addEventListener("DOMContentLoaded", function(event) { 
        //Do work
    });
    

    Note this method will not work on IE8.

    Old Answer:

    You are calling this script before DOM is ready. If you write this code into jquery's $(function() method it will work.

提交回复
热议问题