Starting with something like this:
β<table>
<tr>
<td><input type="text" /></td>
<td><input type="checkbox" /></td>
<td><input type="button" class="addRow" value="Add" /></td>
</tr>
</table>ββββββββββββββββββββββββββββββββββββββββββββββββββββ
This jQuery will work for add / remove:
β$(βββ'table').delegate('βββ.addRow', 'click', function() {
var r= $(this).closest('tr').clone(true);
if(r.find('.removeRow').length === 0)
r.append('<td><input type="button" class="removeRow" value="Remove" /></td>');
r.insertAfter($(this).closest('tr'));
}).delegate('.removeRow', 'click', function() {
$(this).closest('tr').remove();
});
. , , , , ( ..). Add, document.ready, :
$('table tr:first-child')
.append('<td><input type="button" class="addRow" value="Add" /></td>');
β