我有創建的表,顯示添加到數組中的每個項目。每列的最後一行是一個操作字段,可讓您編輯或從行中刪除。我不知道我應該如何完成這一點。我迄今爲止沒有正常工作。嘗試從多維數組中刪除項目(html,javascript)
function del(item) {
participantList.splice(item,1);
displayLIst();
}
function addInfo() {
var fname = document.getElementById("fname").value;
var lname = document.getElementById("lname").value;
var email = document.getElementById("email").value;
if(fname !='' && lname !="" && email !='') {
participantList[count] = new Object();
participantList[count].Fname = fname;
participantList[count].Lname = lname;
participantList[count].Email = email;
participantList[count].Action = "<button onclick='del("+count+")'>Delete</button>" + "<button onclick='edit("+count+")'>Edit</button>";
count++;
document.getElementById("fname").value ="";
document.getElementById("lname").value = "";
document.getElementById("email").value = "";
}
displayList();
}
我想刪除數組中指定行的每個對象。