【发布时间】:2011-09-17 11:07:31
【问题描述】:
我不知道如何解决这个问题。我想更改某些事件的(DOM)源代码,如下所示:
脚本:
<script type="text/javascript">
function ChangeText(){
document.getElementById("p1").innerHTML="New text!";
}
</script>
html:
<p id="p1">Hello world!</p>
<input type="button" onclick="ChangeText()" value="Change text" />
好吧,当我单击按钮时,这工作正常。但是当我查看源代码时,它仍然看起来像这样:
<html>
<body>
<p id="p1">Hello world!</p>
<input type="button" onclick="ChangeText()" value="Change text" />
</body>
</html>
代替:
<html>
<body>
<p id="p1">New text!</p>
<input type="button" onclick="ChangeText()" value="Change text" />
</body>
</html>
【问题讨论】:
-
就是这样。源代码不变。
-
好的,我想我可以更改源代码。所有的建议都会被考虑。非常感谢你们,伙计们。
标签: javascript innerhtml