添加节点问题
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div di="parent">
<!-- <p title="123"></p> -->
</div>
</body>
<script type="text/javascript">
var parent=document.getElementById("parent");
var pid=document.createElement("p");
parent.appendChild(pid);
pid.setAttribute("title","123");
</script>
</html>
求助大佬
其中parent.appendChild(pid);为什么会报出Uncaught TypeError: Cannot read property 'appendChild' of null