1 Star 0 Fork 98

陈伟杰20002090303/npi_exercise04

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
moutains.html 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
timshaw9791 提交于 2021-04-15 12:56 . init commit
<body>
<h1>Mountains</h1>
<div id="mountains"></div>
<div id="mountains" onload="create()">
</div>
<script>
const MOUNTAINS = [
{name: "Mont Blanc", height: 4808, place: "Italy/France"},
{name: "Popocatepetl", height: 5465, place: "Mexico"}
];
// Your code here
onload = function() {
var c = function(c) {
return document.createElement(c);
}
var mytable = c("table");
var mytbody = c("tbody");
document.body.appendChild(mytable);
mytable.appendChild(mytbody);
for (var i = 0; i < MOUNTAINS.length; i++) {//i<MOUNTAINS.length改动
var mytr = c("tr");
mytbody.appendChild(mytr);
for (var j = 0; j < 3; j++) {
var mytd = c("td");
mytr.appendChild(mytd);
if(j==0){
var mytxt = document.createTextNode(MOUNTAINS[i].name);
}else if(j==1){
var mytxt = document.createTextNode(MOUNTAINS[i].height);
}else if(j==2){
var mytxt = document.createTextNode(MOUNTAINS[i].place);
}
//var mytxt = document.createTextNode(MOUNTAINS[i].name);//MOUNTAINS[i].name改动
mytd.appendChild(mytxt);
mytd.width = 200;
mytd.height = 50;
}
}
mytable.setAttribute('border', '1px');
}
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nuanshen0/npi_exercise04.git
git@gitee.com:nuanshen0/npi_exercise04.git
nuanshen0
npi_exercise04
npi_exercise04
master

搜索帮助