日期:2014-05-16 浏览次数:20329 次
function createNewDiv(){ var a = new Array(); var len=-1; //测试数据 while((++len)<10){ a[len].push("title."+len+".1"); a[len].push("content."+len+".1"); } len=-1; var div = document.createElement("div"); div =document.body.appendChild(div); while((++len)<10){ var dl = document.createElement("dl"); dl = div.appendChild(dl); var ltlen=-1; while((++ltlen)<2){ var dt = document.createElement("dt"); dl.appendChild(dt); dt.innerHTML = a[len][ltlen]; } } }
------解决方案--------------------
window.onload = function () { var arr = [ { "Number": "1", "Title": "1.1", "Content": "1.1内容" }, { "Number": "2", "Title": "2.1", "Content": "2.1内容" }, { "Number": "3", "Title": "3.1", "Content": "3.1内容" }, { "Number": "4", "Title": "4.1", "Content": "4.1内容" }, { "Number": "5", "Title": "5.1", "Content": "5.1内容" }, { "Number": "6", "Title": "6.1", "Content": "6.1内容" }, { "Number": "7", "Title": "7.1", "Content": "7.1内容" }, { "Number": "8", "Title": "8.1", "Content": "8.1内容" }, { "Number": "9", "Title": "9.1", "Content": "9.1内容" }, { "Number": "10", "Title": "10.1", "Content": "10.1内容" } ]; var objDiv = document.createElement("div"); objDiv = document.body.appendChild(objDiv);