JSFiddle - React, Tailwind, and code Playground

by Reigel Gallarde

HTML

<button id="add_row">Add Row</button>
<table id="table" border="1" width="100%">
    <tr>
        <td> I'm data </td>
        <td> <button>Delete?</button> </td>
    </tr>
</table>

JavaScript

$(document).ready(function() {
    $('#add_row').click(function() {
        $('#table tr:last-child').after("<tr><td> I'm data " + Math.random() * 10 + " </td><td><button>Delete?</button> </td></tr>");
    });
    
    
    $('#table').delegate('tr','click',function(){
        $(this).closest('tr').remove();
    });
});