var table = document.getElementById("table-body");
var row = table.insertRow(-1);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML = ingredient_name;
cell2.innerHTML = ingredient_amount;
cell3.innerHTML = ingredient_unit;
cell4.innerHTML = '<button type="button" class="close" aria-.hidden="true"onClick="$(this).closest(\'tr\').remove()">×</button>';
如何設置我剛創建的行或表的ID?如何設置新創建的表格行或單元格的ID?
沒有設置'row.id = 「行號」;'不行? – squid314
我不斷收到函數沒有定義的錯誤 – user2179936