<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jsbasicversion8</title>
<script type="text/javascript" src="jsversion8.js" ></script>
</head><body>
<h1 id="message">
this message will be replaced!
</h1>
</body>
</html>//上面是HTML代码,调用下面的JS。是不是我的JS写的有问题。 我想把H1的内容替换掉。就这么简单,请大哥美女们帮看看。
是不是用能用JS 来写,而要用DOM 的 getAttribut(), setAttribut写才行呢?
window.onload = writeMessage;function writeMessage(){
document.getElementById("message").innerHTML="hello world!";