为什么不 innerHtml
工作?
<script src="jquery.js"></script>
<script type="text/javascript">
function chat()
{
alert ("started!");
document.getElementById("test").innerHtml="foo";
}
</script>
<body id="body" onload="chat();">
<p id="test">
test..
</p>
</body>
“开始了!”正在显示,但 <p>
的内容不会更改为 foo
如预期。为什么?
最佳答案
大小写很重要,它是 innerHTML
不是 innerHtml
。试试这个:
document.getElementById("test").innerHTML="foo";
关于javascript - 为什么 innerHtml 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15120572/