How does jquery get the parent tr of an element

<table>
    <tr>
        <td>1</td>
        <td><span>22</span></td>
        <td><span><input type="text" id="ipt1"></span></td>
    </tr>
    <tr>
        <td>1</td>
        <td><span>22</span></td>
        <td><span><input type="text" id="ipt2"></span></td>
    </tr>
    ...
</table>

for example, this -sharpipt1 , what is the most convenient way to get the tr where it is located? Use jquery

Jun.23,2022

$('- sharpipt') .parent () can be obtained.


$('- sharpipt1'). Parent


var tr = $("-sharpipt1").parents("tr");
Menu