I have code which generate table. You can see below the code:
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);
}
}
the results are:
<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>
I wish to add each <td></td> => <td><input><input/></td> Tagas. How I can do that?
Modify your function a bit, and it will add
inputfields to each cell:DEMO: http://jsfiddle.net/Xt33h/