请问我直接使用innerHTML为什么不能修改掉h3标签里面的内容的
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>系好安全带,准备启航</title> <script type="text/javascript"> var charater1 = document.getElementById("div1"); function showText(){ charater1.innerHTML = "hello world"; document.write(charater1.innerHTML); } function showDialog(){ confirm("准备好了,启航吧!"); } </script> </head> <body> <h3 id="div1">let us study JS</h3> <form> <input type="button" value="showText" onclick=showText()> <input type="button" value="showDialog" onclick=showDialog()> </form> </body> </html>
我想把 h3 里面的内容还为 hello world, 但是没有成功。请问这么样才可以替换?