js数组导入列表中
我想把两行三列的数组导入列表中怎么导啊?a=[[b,c,d],[e,f,g]]<ul><li><span></span><span></span><span></span...
我想把两行三列的数组导入列表中怎么导啊?
a=[[b,c,d],[e,f,g]]
<ul>
<li>
<span></span>
<span></span>
<span></span>
</li>
<li>
<span></span>
<span></span>
<span></span>
</li>
</ul> 展开
a=[[b,c,d],[e,f,g]]
<ul>
<li>
<span></span>
<span></span>
<span></span>
</li>
<li>
<span></span>
<span></span>
<span></span>
</li>
</ul> 展开
1个回答
展开全部
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RunJS</title>
<script>
var a=[["b","c","d"],["e","f","g"]];
onload=function(){
var ul=document.createElement("ul");
ul.style.listStyle="none";
for(var i=0;i<a.length;i++){
var ai=a[i];
var li=document.createElement("li");
for(var j=0;j<ai.length;j++){
var span=document.createElement("span");
span.innerHTML=ai[j];
span.style.margin="10px";
li.appendChild(span);
}
ul.appendChild(li);
}
document.body.appendChild(ul);
}
</script>
</head>
<body>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询