JSFiddle - React, Tailwind, and code Playground

HTML

<table class="mytable">
    <tr>
        <td>1001</td>
        <td>apples</td>
    </tr>
    <tr>
        <td>1002</td>
        <td>bananas</td>
    </tr>
</table>
<button id="mybutton">Button</button>
<button id="mybutton2">Button2</button>

JavaScript

$('#mybutton').click(function(){
    $('.mytable td').parent().hide();
    $('.mytable td:contains("apples")').parent().show();
});

$('#mybutton2').click(function(){
    $('.mytable td:not(:contains("apples"))').parent().hide();
});