问答详情
源自:1-1 为什么学习JavaScript

提示Uncaught TypeError: Cannot read property 'style' of null at ZUOSHIYAN.html:14

<!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=“p1”>我是第一段文字</p>

<p id="p2">我是第二段文字</p>

<script type="text/javascript">

document.write("hello");

document.getElementById("p1").style.color = "blue";

</script>

</body>

</html>


请问这是哪里错了

提问者:慕粉1329267929 2019-07-27 15:24

个回答

  • weibo_慕少4347550
    2019-07-27 15:37:12
    已采纳

    第10行,p1引号你用的是中文的。。。

  • 慕莱坞1394360
    2019-07-27 15:40:41

    应该就是符号的中英文问题,你的  document.write("hello"); 这行的“ ;” 就是中文的