新手求解???
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>初識css</title>
<script type="text/javascript">
document.write("hello");
document.getElementById("p1").style.color="blue";
</script>
</head>
<body>
<p id="p1">我是第一段文字</p>
<p id="p2">我是第二段文字</p>
</body>
</html>
為什么P1不顯示為藍色?
2015-11-25
因為你的js代碼執(zhí)行時,頁面的p標簽還沒有生成。