0
這是我的代碼如何用javascript刪除表上的特定行?使用使用document.createElement()
function AddItemOnTable(){
if(getCookie("no") == null){
var no = 1;
}else if(parseInt(getCookie("no")) > 0){
var no = getCookie("no");
}else{
var no = 1;
}
var tableRef =
document.getElementById('whatToBuy').getElementsByTagName('tbody')[0];
var newRow = tableRef.insertRow(tableRef.rows.length);// Nambahin row di
tabel diurutan terakhir
var cell_no = newRow.insertCell(0);// Tambah row pada index yang ke 0
var newText = document.createTextNode(String(no));// Memberikan text
cell_no.appendChild(newText);
no = String(parseInt(no) + 1);
document.cookie = "no="+no;
var cell_btn = newRow.insertCell(7);
var input = document.createElement("input");
input.type = "button";
input.className = "button";
input.value = "x";
var index = parseInt(no-2);
//alert(index);
input.onclick = "DeleteRow(index)";
cell_btn.appendChild(input);
}
function DeleteRow(no){
document.getElementById("whatToBuy").deleteRow(no);
alert("a");
}
:input.onclick = 「DeleteRow(索引)」;
爲什麼它不會調用「刪除行」功能? 對不起我的英語不好,即時通訊新的網頁開發:D