JSFiddle - React, Tailwind, and code Playground
by adamzr
HTML
<table id="myTable">
<tbody>
<tr>
<td>Row</td>
</tr>
</tbody>
</table>
<button id="add">Add Row</button>
<button id="remove">Remove Row</button>
JavaScript
$("#add").click(function(){
$("#myTable tbody").append("<tr><td>New Row</td></tr>");
});
$("#remove").click(function(){
$("#myTable tbody tr").eq(0).remove();
});
var numberOfRows = $("#myTable>tbody>tr").length;
$("#myTable").bind("DOMSubtreeModified", function() {
if($("#myTable>tbody>tr").length !== numberOfRows){
numberOfRows = $("#myTable>tbody>tr").length;
alert("row count changed..");
}
});