日期:2014-05-16 浏览次数:20377 次
json={ "people": [
{ "Col01": "姓名", "Col02":"年龄", "Col03": "手机" }
]}
var tHead= "<tr>";
tHead+= "<td width='40' class='bg_thead center'>序号</td>"
$.each(json.people, function(key, val) {
tHead+=
});
var $json='{"people": [{ "Col01": "姓名", "Col02":"年龄", "Col03": "手机"}]}';
var $o = $.parseJSON($json);
var tHead= "<tr>";
tHead+= "<td width='40' class='bg_thead center'>序号</td>"
$.each($o.people,function(k,v){
$.each(v,function(k1,v1){
tHead+="<td width='40' class='bg_thead center'>"+ v1 + "</td>";
})
})
tHead+='</tr>';
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
json={ "people": [
{ "Col01": "姓名", "Col02":"年龄", "Col03": "手机" }
]}
var tHead= "<tr>";
tHead+= "<td width='40' class='bg_thead center'>序号</td>"
$.each(json.people, function (key, val) {
for (k in this) tHead += '<td>' + this[k] + '</td>';
});
document.write('<table>'+tHead+'</table>');
</script>