我想为我的行动态设置 ID。我有这个:
function (json) {
for (var ib = 0; ib < json.length; ib++) {
var tableib = document.getElementById("treatments");
var treatmentId = json[ib].id;
var rowib = tableib.insertRow(-1);
var cell1ib = rowib.insertCell(0);
var cell2ib = rowib.insertCell(1);
var cell3ib = rowib.insertCell(2);
var cell4ib = rowib.insertCell(3);
var cell5ib = rowib.insertCell(4);
var buttonID = json[ib].id;
cell1ib.innerHTML = json[ib].name;
cell2ib.innerHTML = json[ib].time;
cell3ib.innerHTML = json[ib].price + "kr";
cell4ib.innerHTML = json[ib].details;
cell5ib.innerHTML = "Button";
}
});
我要设置的 ID 来自 JSON 响应并具有变量buttonID。这甚至可能还是我应该像这样附加每一行?:
$('#treatments').append("<tr><td>" + shopName + "</td><td>" + shopTime + "</td><td>" + shopPrice + "</td><td>" + shopDetails + "</td><td><center>" + editShop + deleteShop + "</center></td></tr>");
我可以在其中更改附加的字符串。