Given error Uncaught TypeError: Cannot set property 'innerHTML' of null when button is clicked

Given error Uncaught TypeError: Cannot set property 'innerHTML' of null when button is clicked

我的代码中显示错误。

使用此按钮:

 <button style="display:none" id="saveH" class="btn btn-primary" onclick="makeToDoList(); displayTDL();">Save</button> 

单击该按钮时,它假设会显示一个 div,其中列出了用户在“表单”中输入的内容。但是,当我 运行 代码时,它给了我这个错误: 1025:59 Uncaught TypeError: Cannot set 属性 'innerHTML' of null

Here is a link to a JSFiddle with my code

错误

Uncaught TypeError: Cannot set property 'innerHTML' of null

表示不能设置null值的innerHTML属性。 null 值是 getElementById() 查询的结果,结果为空。

所以看看错误发生在哪一行你可以看到它不能设置的innerHTML result9h 元素。那是因为它不存在于您的 HTML.