嘿,我想提出一个网站,只是JavaScript,但我得到这个错误:JavaScript的网站错误:未捕获的类型错误:无法执行“的appendChild”的“节点”
Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'at html:12:9
这里是我的html代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<script>
var divEl = document.createElement("div");
document.body.appendChild(divEl);
var ptag = document.createElement("p").setAttribute("id", "lol");
divEl.appendChild(ptag);
</script>
</body>
</html>
'document.createElement(“p”)。setAttribute(“id”,“lol”);'不返回节点。 – vlaz