我有生成表格的代码。你可以看到下面的代码:
function createDynamicTable(tbody, rows, cols) {
if (tbody == null || tbody.length < 1) return;
for (var r = 1; r <= rows; r++) {
var trow = $("<tr>");
for (var c = 1; c <= cols; c++) {
var cellText = "Cell " + r + "." + c
$("<td>")
.addClass("tableCell")
.text(cellText)
.data("col", c)
.appendTo(trow);
}
trow.appendTo(tbody);
}
}
结果是:
<table id="tbl" border="1">
<tbody>
<tr>
<td class="tableCell">Cell 1.1</td>
<td class="tableCell">Cell 1.2</td>
<td class="tableCell">Cell 1.3</td>
<td class="tableCell">Cell 1.4</td>
</tr>
</tbody>
</table>
我希望添加每个<td></td>
=> <td><input><input/></td>
Tagas。我怎么能这样做?