2-4编程练习
来源:2-4 编程练习
慕粉1110144175
2019-03-07 10:49:42
<!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>
//在此处补充代码
var ul=document.createElement('ul');
var comment=document.createComment("创建节点");
var fra=document.createDocumentFragment();
var li=null;
var text="";
for(var i=0;i<3;i++){
li=document.createElement('li');
text=document.createTextNode("第"+(i+1)+"个li");
li.appendChild(text);
li.className="li";
fra.appendChild(li);
}
ul.appendChild(fra);
document.body.appendChild(ul);
document.body.insertBefore(comment,document.body.firstChild);
</script>
</body>
</html>1回答
好帮手慕糖
2019-03-07
同学你好,实现没有问题,继续加油!欢迎采纳。
祝学习愉快!
相似问题