JSFiddle - React, Tailwind, and code Playground
by j08691
HTML
<table id="mytable">
<thead>
<tr>
<thead>My Date</thead>
</tr>
</thead>
<tbody>
<tr>
<td>
<input class="datepicker" type="text" />
</td>
</tr>
</tbody>
</table>
<button id="add-row" type="button">Add Row</button>
JavaScript
$(document).on('focus', ".datepicker", function () {
$(this).datepicker( "destroy" ).datepicker();
})
$("#add-row").on("click", function () {
addRow("#mytable");
});
function addRow(tableId) {
// clone the last row in the table
var tr = $(tableId).find("tbody tr:last").clone();
// clear the values in the new row
tr.find("input").val('');
tr.find("select").val('');
// append the new row to the table
$(tableId).find("tbody tr:last").after(tr);
}