<script type="text/javascript">
var mychar= document.getElementById("h2");
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello world!";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
var mychar= document.getElementById("h2");这儿错了,应该是ID而不是标签
<script type="text/javascript">
var mychar= document.getElementById('con'); //是ID 不是标签
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello World";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
正确的呀