我的代码在这里:
https://codepen.io/ChocolateRoca/pen/qXdoNV
我相信这段代码是罪魁祸首,但我不确定如何解决它:
$('tbody tr'+row_counter.toString()).append(
"<td>"+ entree[row_counter]['gsx$employer']['$t'] +"</td>"+
"<td>"+ entree[row_counter]['gsx$title']['$t'] +"</td>"+
"<td>"+ entree[row_counter]['gsx$location']['$t'] +"</td>"+
"<td>"+ entree[row_counter]['gsx$employerorganizations']['$t'] +"</td>" +
"<td>"+ entree[row_counter]['gsx$typeofjob']['$t'] +"</td>"
)
row_counter += 1;
});
简要说明:
我正在从公开的谷歌电子表格中提取数据,其数据我已转换为JSON,因此我可以将其提取到代码集。
该代码应该在(th)单元下均匀分布(td)单元,但是所有td单元都在第一个单元下填充。我该如何修理?
答案 0 :(得分:-1)
您可以尝试编辑JS的这一部分:
$(entree).each(function(){
var current_tr = "<tr class=\"tr" + row_counter.toString()+"\">";
var current_tr_name = "tr"+ row_counter.toString();
$('tbody').append(current_tr + "</tr>")
$('tbody .tr'+row_counter.toString()).append(
"<td>"+ entree[row_counter]['gsx$employer']['$t'] +"</td>"+
"<td>"+ entree[row_counter]['gsx$title']['$t'] +"</td>"+
"<td>"+ entree[row_counter]['gsx$location']['$t'] +"</td>"+
"<td>"+ entree[row_counter]['gsx$employerorganizations']['$t'] +"</td>" +
"<td>"+ entree[row_counter]['gsx$typeofjob']['$t'] +"</td>"
)
row_counter += 1;
});
为我工作..