[英]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.