JSFiddle - React, Tailwind, and code Playground
by Jinhui LEE
HTML
<button id="addTR">Add</button>
<table id="table">
<tr>
<td><input type="text" name="idx[]" value="" /></td>
</tr>
</table>
JavaScript
$(function() {
$("#addTR").click(function () {
var row = "<tr>";
row += "<td><input type='text' name='idx[]' value='' /></td>";
row += "<td><span>Remove</span></td>";
row += "</tr>";
$("#table").append(row);
});
$("#table").on("click", "span", function() {
$(this).closest("tr").remove();
});
});