JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <tbody>
        <tr id='0'>
            <td>Row 1</td>
        </tr>
        <tr id='1'>
            <td>Row 2</td>
        </tr>
        <tr id='2'>
            <td>Row 3</td>
        </tr>
        <tr id='3'>
            <td>Row 4</td>
        </tr>
    </tbody>
</table>

JavaScript

$("tr").click(function () {
    $(this).remove();
    $("tr").prop("id", function () {
        return $(this).index();

    });


});