为什么 var 值没有显示在 id 元素中?
我尝试了很多次但没有成功,我该怎么做?
<script>
var xxxx = "test";
//alert(xxxx);
document.getElementById("here").innerHTML = xxxx;
</script>
<span id="here"></span>
最佳答案
试试这个:
<span id="here"></span> <script> var xxxx = "test"; //alert(xxxx); document.getElementById("here").innerHTML = xxxx; </script>
看看 Why does jQuery or a DOM method such as getElementById not find the element? ,正如 @Teemu 所建议的。
关于javascript - 为什么 var 值不显示在 id 元素中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27471908/