从控制台显示数据时,我得到了:
0: {smname: "thor", sim: "9976680249", pondo: "10"}
1: {smname: "asd", sim: "9999999999", pondo: "0"}
2: {smname: "asd", sim: "4444444444", pondo: "0"}
3: {smname: "bcvb", sim: "7867896786", pondo: "0"}
4: {smname: "fgdg", sim: "5464564564", pondo: "0"}
5: {smname: "throw", sim: "zxcxxxxxxx", pondo: "0"}
length: 6
我对JS有问题,它不会显示到我的HTML表中。这是我的 JS:
let a = 1;
if(data.includes("NO PIN")){
alert(data);
}else{
$("#aname").text("");
$("#asim").text("");
$("#pinpass").text("");
console.log(data);
$("#divaddnew").html("");
a = data.length;
for(let x=0; x < data.length; x++){
let agentsz =
`<tr class="clr">
<td align=center>${data[x].smname}</td>
<td align=center>${data[x].sim}</td>
<td align=center>${data[x].pondo}</td>
</tr>`
$("#agentss").after(agentsz);
a--;
}
}
这是我的HTML表格:
<tbody>
<tr id="#agentss">
</tr>
</tbody>
答案 0 :(得分:2)
尝试从HTML的ID中删除“#”:
<tbody>
<tr id="agentss">
</tr>
</tbody>
(但将其保留在您的jquery选择器中)