JSFiddle - React, Tailwind, and code Playground

HTML

<table>
    <tr>
        <td>Foo bar</td>
        <td>Foo bar2</td>
    </tr>
    <tr>
        <td>Bar</td>
        <td>Bar2</td>
    </tr>
    <tr>
        <td>Foo bar</td>
        <td>Bar2</td>
    </tr>
</table>

CSS

.selected {
    background-color: red;
}

JavaScript

$('td').filter(function() {
    return $(this).text().indexOf('Foo') === 0;
}).closest('tr').toggleClass('selected');