JSFiddle - React, Tailwind, and code Playground
by Kevin Faulhaber
HTML
<table id="maintable">
<tr>
<td>test</td>
<td>test2</td>
<td>test3</td>
</tr>
</table>
<button id="Addmore">add</button>
<button id="remove">remove</button>
JavaScript
$("#remove").click(function () {
$('#maintable td').one('click', function(){
$(this).remove();
});
});
$("#AddMore").click(function () {
$("#maintable").each(function () {
var tds = '<tr>';
jQuery.each($('tr:last td', this), function () {
tds += '<td>' + $(this).html() + '</td>';
});
tds += '</tr>';
if ($('tbody', this).length > 0) {
$('tbody', this).append(tds);
} else {
$(this).append(tds);
}
});
});