JSFiddle - React, Tailwind, and code Playground

HTML

<table border="1">
<tr>
    <th><button class="toggle" id="1" onclick="func(this.id);" >hide</button></th>
    <th><button class="toggle" id="2" onclick="func(this.id);" >hide</button></th>
</tr>

<tr>
  <td class="col1"> <div>row 1, cell 1</div></td>
  <td class="col2"> <div>row 1, cell 2</div></td>
</tr>
 
<tr>
  <td class="col1"><div>row 2, cell 1</div></td>
  <td class="col2"> <div>row 2, cell 2</div></td>
  </tr>
  </table>

JavaScript

$(".toggle").click(function() {
    $(this).parent().hide();
    $(".col" + $(this).attr("id")).hide();
});