【发布时间】:2014-03-22 05:24:49
【问题描述】:
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?
【问题讨论】:
-
设置
row.id = "row-id";不起作用吗? -
我不断收到函数未定义错误
标签: javascript jquery dynamic html-table attr