JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" id="contains" >contains text2
    <br/>
<input type="checkbox" id="notContains">not:contains text2
<table border="1" style="text-align:center;">
    <tr>
        <th>Name</th><th>Lastname</th>
    </tr>
    <tr>
        <td>text1</td><td>text2</td>
    </tr>
    <tr>
        <td>text3</td><td>text4</td>        
    </tr>
</table>

JavaScript

$('#contains').change( function() {
        $('td:contains("text2")').parent().toggle();
    });

    $('#notContains').change( function() {
        $('td:first-child').parent('tr:not(:contains("text2"))').toggle();
    });