我刚开始学习JavaScript,但我觉得我已经懂了。我不明白为什么它不能工作。当按钮被点击时,我需要将“this text”作为二级标题的格式插入到theDiv
中。我尝试过各种方法,甚至使用函数。这个例子看起来应该可以工作,但是却没有。我必须只使用JavaScript来使其工作,不能用jQuery - 因为我还不会。
<html>
<h1 id="header">Header in progress</h1>
<body>
<p>
<input type="button" id="theButton" value="click me!" onclick="document.getElementById('theDiv').innerHTML('This is new.')">
</p>
<h3><div id="theDiv"></div></h3>
</body>
</html>