亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

新手求解???

<!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不顯示為藍色?

正在回答

1 回答

<!doctype?html>
<html>
<head>
????<meta?http-equiv="content-type"?content="text/html;?charset=utf-8">
????<title>初識css</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>

因為你的js代碼執行時,頁面的p標簽還沒有生成。

0 回復 有任何疑惑可以回復我~
#1

qq_嘴角洋溢起的一絲微笑_0 提問者

非常感謝!
2015-11-26 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
JavaScript入門篇
  • 參與學習       741186    人
  • 解答問題       9866    個

JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門

進入課程

新手求解???

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號