JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <tbody id="sortable">
        <tr id="row1">
            <td><a href="#" class="top">Top1</a></td>
        </tr>
        <tr id="row2">
            <td><a href="#" class="top">Top2</a></td>
        </tr>
        <tr id="row3">
            <td><a href="#" class="top">Top3</a></td>
        </tr>
    </tbody>
</table>

JavaScript

$(function() {
    $(".top").click(function() {
        var thisRow = $(this).parent().parent();
        var firstRow = thisRow.parent().find("tr:first").not(thisRow);
        alert(thisRow);
        alert(firstRow);
        thisRow.insertBefore(firstRow);
    });
});