[英]Why is my webpage saying [object HTMLParagraphElement]?
when I try to use javascript to write to an id in html, I get this: [object HTMLParagraphElement] I am using innerhtml but it still doesn't work.当我尝试使用 javascript 写入 html 中的 id 时,我得到这个:[object HTMLParagraphElement] I am using innerhtml 但它仍然不起作用。 I looked at different answers but none seemed to help
我查看了不同的答案,但似乎没有任何帮助
here is my code:这是我的代码:
var cashs = 0;
<p id="cashs"></p> <script>document.getElementById('cashs').innerHTML = cashs;</script>
Because any element in the document that contains `id' is defined in the code as a variable that indicates its element by default因为文档中任何包含 `id' 的元素在代码中都定义为变量,默认表示其元素
<p id="a"></p>
<script type="text/javascript">
a.innerHTML="Hello";
</script>
Results:结果:
<p id="a">Hello</p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.