我想在下面添加标题,但我无法这样做。我到处搜索,但仍然没有。我对此仍然很新,但任何帮助都将不胜感激。你能帮忙吗?
function myFunction(response) {
var arr = JSON.parse(response);
var i;
var out = "<table>";
for(i = 0; i < arr.length; i++) {
out += "<tr><td>" +
arr[i].id +
"</td><td>" +
arr[i].bkname +
"</td><td>" +
arr[i].pbname +
"</td><td>" +
arr[i].year +
"</td><td>" +
arr[i].type +
"</td><td>" +
arr[i].con +
"</td></tr>";
}
out += "</table>"
document.getElementById("id01").innerHTML = out;
}
答案 0 :(得分:0)
将标题放在初始值out
var out = "<table><tr><th>ID</th><th>BKName</th><th>PBName</th><th>Year</th><Type</th><th>Con</th></tr>";