用js创建ul列表一定要写在同一个body或者head里面吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<div>
<ul id="menu">
<li id="0" >常用操作</li>
</ul>
</div>
<script type="text/javascript">
var tbody = document.createElement("tbody");
var aa=new Array();
for(i=0;i<2;i++)
{
var ul = document.createElement("ul");
aa[i]=new Array();
var li = document.createElement("li");
li.innerHTML = getValue(i);
ul.appendChild(li);
tbody.appendChild(ul);
}
var parNode = document.getElementById("menu");
parNode.appendChild(tbody);
function getValue(i)
{
var values = new Array();
var people ={"programmers":[{"name": "旅游城市信息管理"},
{"name":"新添求助信息关系"}
]}
values[0] = new Array();
values[1] = new Array();
values[0] = people.programmers[0].name;
values[1] = people.programmers[1].name;
return values[i];
}
</script>
</body>
</html>