JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <tr>
        <th><input type="text" name="num" value="num"/></th>   
        <th><input type="text" name="a" value="a"/></th>
    </tr>
    
    <tr >
        <td> <input type="text" name="num" value=""/> </td>
        <td><input type="text" name="a" value=""/></td>
    </tr>
</table>

CSS

.highlight {
    background-color: blue;
}

JavaScript

$(function(){

    
    
    $("tr input").click(function(){       
         $(this).closest('table').find('.highlight').removeClass("highlight");
         $(this).closest('tr').find('input').toggleClass("highlight");
    });
        
})