creatTextNode这么简单的代码为什么就是出问题

这个代码就几行,为什么没反应??崩溃了
<html>
<body>

<script >
e1=document.createElement("p");
t1=document.createTextNode("jdjs");
e1.appendChild(t1);
</script>

</body>
</html>

阅读 2.6k
3 个回答

1,create单词拼错
2,需要将e1加入到dom树上

e1=document.createElement("p");
t1=document.createTextNode("jdjs");
e1.appendChild(t1);
document.body.appendChild(e1);

肯定没反应啊,你没有把e1加入到dom树中

e1还没被append到页面上呢

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题