<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<p id="con">Hello world!</p>
<script>
var mycon=document.getElementById("con");
document.write("P标签原始内容为"+mycon.innerHTML+"<br/>");
mycon.innerHTML="New text!";
document.write("P标签修改内容为"+mycon.innerHTML);
</script>
</body>
</html>
是按照顺序依次执行的,你可以将 mycon.innerHTML="New text!";先注释了,就可以知道他<p id="con">Hello world!</p>是有打印出来的,但是浏览器执行到 mycon.innerHTML="New text!";就将p标签里面的文字给修改了