Slightly strange question, but I have a for loop that loops through, and builds a list:
function buildList(jsonList) {
var list = "<tbody>";
for (i = 0; i < jsonList.length; i++) {
list += "<ul class ='list'>";
list += "<li>" + jsonList[i].keyNumber + "</li>";
list +=
"<li>" +
"<button type='button' class='btn' onclick='deleteRow(this)'>" +
"Remove" +
"</button>" +
"</li>";
list += "</ul>";
}
list += "</tbody>";
document.getElementById("htmlList").innerHTML = list;
}
Is there anyway I can pass the jsonList[i].keyNumber
value to inside my onlick function inside my button?
onclick= 'deleteRow(this, jsonList[i].keyNumber)'
.
That way, deleteRow
will know which list to delete.
I would like to keep the above format and not use Jquery.
I need the ID, sending it to an API
`s should not be children of ``s
– CertainPerformance Feb 16 '20 at 23:49` `- ` ? this is illogical!
– Mister Jojo Feb 16 '20 at 23:51