在HTML中插入对象数据
这个问题在这里已经有了答案:
刚刚循环,创建HTML字符串,并追加! 假设你有一个容器:
<div id="container"></div>
和你的JS
var htmlString = "";
for (var key in lists) {
htmlString += "<span>" + key + "</span>";
htmlString += "<ul>";
for (var item in lists[key]) {
htmlString += "<li>" + item + " = " + lists[key][item] + "</li>";
}
htmlString += "</ul>";
}
document.getElementById("container").innerHTML = htmlString;
工作演示:http://jsfiddle.net/owqt5obp/
链接地址: http://www.djcxy.com/p/52009.html