老师帮忙看看错在哪
来源:6-4 编程练习
weixin_慕UI3466417
2020-04-15 11:13:44
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.li{list-style:none;height:50px;line-height:50px;width:100px;background-color:lightblue;text-align:center;}
</style>
</head>
<body>
<script>
//在此处补充代码
(function(){
var ul=document.createElement("ul").appendChild("body");
var frag=document.createDocumentFragment();
var li=null;
for(var i=0;i<3;i++){
li=document.createElement("li");
li.appendChild(document.createTextNode("第"+(i+1)+"个li"));
frag.appendChild(li);
}
ul.appendChild(frag);
})
</script>
</body>
</html>
1回答
好帮手慕粉
2020-04-15
同学你好,关于同学的问题回答如下:
1、同学的函数没有自执行,少了小括号:
2、在将ul向body里面追加的时候,写错了,修改参考:
祝学习愉快~
相似问题