我正在练习javascript,尽管很难理解为什么以下内部html不会更改值。
这是我的代码:
<a href="#" onmousedown="bleep.play()">home</a>
<button onclick="GenerateTitle(1)">Generate</button>
<div id="div1">Default Content...</div>
JAVASCRIPT
var bleep = new Audio();
bleep.src = "sound.mp3";
function GenerateTitle(num){
bleep.play();
var div1= document.getElementById("div1");
div1.innerHtml = "load content for";
}
答案 0 :(得分:2)
实际上是其 innerHTML ,而不是innerHtml
答案 1 :(得分:0)
上述答案应为innerHTML
,请参见下面的代码。我已经修改了代码
var bleep = new Audio();
bleep.src = "sound.mp3";
function GenerateTitle(num){
bleep.play();
var div1= document.getElementById("div1");
div1.innerHTML = "load content for";
}
<a href="#" onmousedown="bleep.play()">home</a>
<button onclick="GenerateTitle(1)">Generate</button>
<div id="div1">Default Content...</div>