// create text <span>
var text = document.createTextNode("Some content I want to replace... ");
var textspan = document.createElement("span");
textspan.id = "text" + counter;
textspan.appendChild(text)
div.appendChild(textspan);
// edit <span> content
document.getElementById("text" + this.index).innerHtml = 'hello';
console.log(document.getElementById("text" + this.index).innerHtml);
console.log(document.getElementById("text" + this.index));
结果
> hello
> <span id="text0">Some content I want to replace </span>
InnerHtml 更改正确,但浏览器(和控制台)仍然显示错误的内容。这是为什么?