<!DOCTYPE html>
<html>
<head>
<script src="/jquery/jquery-1.11.1.min.js">
</script>
<script>
var table;
$(document).ready(function(){
table = $('table');
rows = [
{xh:"学号0",bj:"班级0",na:"名字0",age:"年龄0"}
,{xh:"学号1",bj:"班级1",na:"名字1",age:"年龄1"}
,{xh:"学号2",bj:"班级2",na:"名字2",age:"年龄2"}
,{xh:"学号3",bj:"班级3",na:"名字3",age:"年龄3"}
]
addRows(table,rows);
});
function addRows(table,rows){
for(var i=0;i<rows.length;i++){
var row = rows[i];
var divEle= $('<div id="div'+i+'"></div>');
var trEle = $('<tr></tr>');
var tdEleHtml ='<td id="num'+i + '" style="display:none">'+row.xh+'</td>'
+'<td id="class'+i+'">'+row.bj+'</td>'
+'<td id="name'+i+'">'+row.na+'</td>'
+'<td id="age'+i+'">'+row.age+'</td>';
var tdEles = $(tdEleHtml);
trEle.append(tdEles);
divEle.append(trEle );
table.append(divEle);
}
}
</script>
</head>
<body>
<table>
</table>
</body>
</html>