Is there a really easy way I can take an array of JSON objects and turn it into an HTML table, excluding a few fields? Or am I going to have to do this manually?
A still shorter way
$.makeTable = function (mydata) {
if (mydata.length <= 0) return "";
return $('').append("" + $.map(mydata[0], function (val, key) {
return "" + key + " ";
}).join("\n") + " ").append($.map(mydata, function (index, value) {
return "" + $.map(index, function (val, key) {
return "" + val + " ";
}).join("\n") + " ";
}).join("\n"));
};
- 热议问题