日期:2014-05-16 浏览次数:20359 次
<table height="33" border="0" cellpadding="0" cellspacing="0">
<tr class="rr0">
<td class="row0">id</row>
<td class="row1">name</row>
<td class="row2">age</row>
</tr>
<tr class="rr1">
<td class="row0">id</row>
<td class="row1">name</row>
<td class="row2">age</row>
</tr>
var obj = {"rows":[{"id":"32","name":"nam3e1","age":1},{"id":"32","name":"ana2me1","age":2},{"id":"32","name":"b3name1","age":1},{"id":"32","name":"cna3me1","age":3}]};
var html = '<table height="33" border="0" cellpadding="0" cellspacing="0">';
for(var i in obj.rows){
html+='<tr class="rr'+i+'">\
<td class="row0">'+obj.rows[i].id+'</row>\
<td class="row1">'+obj.rows[i].name+'</row>\
<td class="row2">'+obj.rows[i].age+'</row>\
</tr>';
}
html+='</table>';
console.log(html)
if ( !Array.prototype.forEach ) {
Array.prototype.forEach = function(fn, scope) {
for(var i = 0, len = this.l