輸出時(shí)HELLO為什么不是先輸出的呢
<!DOCTYPE HTML>
<html>?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>熱身</title>
</head>
<body>
? <p id="p1">我是第一段文字</p>
? <p id="p2">我是第二段文字</p>
??
? <script type="text/javascript">
document.write("hello");
document.getElementById("p1").style.color="blue";
? </script>
</body>
</html>
2015-06-06
瀏覽器是順序解析HTML文檔的,當(dāng)p1和p2顯示完后才解析它們后面js文檔
2015-07-31
其實(shí)這個(gè)代碼書(shū)寫(xiě)是不規(guī)范的。
因?yàn)镴S、jequery庫(kù)的引用都是在文檔之前,因?yàn)橐荍S出現(xiàn)問(wèn)題了~就是單純文字~
2015-06-06
代碼是從上往下讀取輸出的啊。。。你的JS寫(xiě)在<p id="p1">我是第一段文字</p>前面 不就先輸出hello了么