JSFiddle - React, Tailwind, and code Playground

HTML

<table width="100%" cellspacing="0" cellpadding="3px">
    <tr>
        <td>
            <input type="button" value="BUTTON1" id="select1" name="select1" onclick="highlight(this)" />
        </td>
        <td>
            <input type="button" value="BUTTON2" id="select2" name="select2" onclick="highlight(this)" />
        </td>
        <td>
            <input type="button" value="BUTTON3" id="select3" name="select3" onclick="highlight(this)" />
        </td>
        <td>
            <input type="button" value="BUTTON4" id="select4" name="select4" onclick="highlight(this)" />
        </td>
    </tr>
</table>

JavaScript

var buttonClicked = null;

  function highlight(element) {
      if (buttonClicked != null) {
          buttonClicked.style.background = "grey";
          buttonClicked.style.color = "black";
      }
      buttonClicked = element;
      buttonClicked.style.background = "red";
      buttonClicked.style.color = "white";
  }