简体   繁体   English

语法中的innerHTML 错误不起作用; 未捕获的类型错误:无法设置 null 的属性(设置“innerHTML”)

[英]innerHTML error in syntax not working; Uncaught TypeError: Cannot set properties of null (setting 'innerHTML')

For some reason I am keep on getting a syntax error from this "innerHTML", can someone help me?出于某种原因,我不断从这个“innerHTML”中收到语法错误,有人可以帮助我吗?

HTML CODE: HTML代码:

JavaScript CODE: document.getElementById("ID").innerHTML = "Test"; JavaScript 代码:document.getElementById("ID").innerHTML = "Test";

Syntax Error: Uncaught TypeError: Cannot set properties of null (setting 'innerHTML')语法错误:未捕获的类型错误:无法设置 null 的属性(设置“innerHTML”)

I am trying to make the div respond with a "Test" using "innerHTML" and "getElementById" but the syntax error is getting in the way.我试图让 div 使用“innerHTML”和“getElementById”以“测试”响应,但语法错误正在妨碍。

The error means that js not found with the selector ID.该错误意味着找不到带有选择器 ID 的 js。 You need ID as a selector.您需要 ID 作为选择器。 Take a look:看一看:

 document.getElementById("ID").innerHTML = "Test";
 <div id="ID">Hello</div>

The error refers to the fact that document.getElementById("ID")´´´ is invalid. Meaning that "ID" is not excisting. In your HTML code there needs to be an object with the该错误是指document.getElementById("ID")´´´ is invalid. Meaning that "ID" is not excisting. In your HTML code there needs to be an object with the的事实document.getElementById("ID")´´´ is invalid. Meaning that "ID" is not excisting. In your HTML code there needs to be an object with the document.getElementById("ID")´´´ is invalid. Meaning that "ID" is not excisting. In your HTML code there needs to be an object with the document.getElementById("ID")´´´ is invalid. Meaning that "ID" is not excisting. In your HTML code there needs to be an object with the id="ID"´´´. document.getElementById("ID")´´´ is invalid. Meaning that "ID" is not excisting. In your HTML code there needs to be an object with the id="ID"´´´ 的对象。

在网页上当前不存在的 ID 上运行 getElementById 会出现此错误,如果您正在处理具有多个场景的项目并且您尝试为当前未显示在屏幕上的场景中的元素调用此它会因为这个错误而出错。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:未捕获类型错误:无法设置 null 的属性(设置“innerHTML”) - Error: Uncaught TypeError: Cannot set properties of null (setting 'innerHTML') 未捕获(承诺中)类型错误:无法设置 null 的属性(设置“innerHTML”) - Uncaught (in promise) TypeError: Cannot set properties of null (setting 'innerHTML') JS 中的错误“Uncaught TypeError: Cannot set properties of null (setting 'innerHTML') at call.html:10:58” - Error in JS "Uncaught TypeError: Cannot set properties of null (setting 'innerHTML') at call.html:10:58" 未捕获的类型错误:无法设置未定义的属性(设置“innerHTML”) - Uncaught TypeError: Cannot set properties of undefined (setting 'innerHTML') document.getElementById 未捕获的类型错误:无法设置 null 的属性(设置“innerHTML”) - document.getElementById Uncaught TypeError: Cannot set properties of null (setting 'innerHTML') 未捕获的TypeError:无法将属性&#39;innerHTML&#39;设置为null - Uncaught TypeError: Cannot set property 'innerHTML' of null 未捕获的Typeerror:无法将属性innerHTML设置为null - Uncaught Typeerror: Cannot set property innerHTML of null 未捕获的TypeError:无法将innerHTML设置为null - Uncaught TypeError: Cannot set innerHTML to null 未捕获的TypeError:无法将属性&#39;innerHTML&#39;设置为null - Uncaught TypeError: Cannot set property 'innerHTML' of null 未捕获的TypeError:无法将属性&#39;innerHTML&#39;设置为null - Uncaught TypeError: Cannot set property 'innerHTML' of null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM