I have a table with a row and two TDs
<table id="tbTest">
<tr>
<td>
<input type="text">
</td>
<td>
<input type="text">
</td>
</tr>
</table>
I also have a button that adds a new row with a td dynamically. If the second time is clicked I want to add a second td. if the third time is clicked I want to add a new tr with one td...etc
jquery on click
var counter = 2;
if ((counter % 2) == 0) {
row = $('<tr><td><input type="text"/></td></tr>');
}
else {
//???????????????
}
row.appendTo('#tbTest');
counter++;
I can add a tr and td (first time clicked) but the second time clicked how do I insert a second td in a tr... suggestions?
thanks,
tds are in the last row. If there are already two, add a new row.