JSFiddle - React, Tailwind, and code Playground

HTML

<table id="tblTest">
    <tr>
        <td>
            <input type="text" id="txtTest" onclick="getParent.call(this)" />
        </td>
    </tr>
</table>

JavaScript

function getParent()
{
  var t = this.parentNode;
  tagName = "table";

  while (t) {
  if (t.tagName && t.tagName.toLowerCase() == tagName) {
      alert(t.id);
      return;
    }
      else
      {
          t = t.parentNode;
      }
 
  }
    return null;
}