JSFiddle - React, Tailwind, and code Playground

HTML

<table><tr><td>hello!</td></tr></table>
<p></p>
<div>click me</div>

JavaScript

var cap_check=(function() {
    var row;
    $('td').click(function(){ 
        row = $(this).parent().parent().children().index($(this).parent());  
        alert(row);
    }); 
    return function() {
       alert(row);
    };
}());

$('div').click(function() {
   cap_check(); 
});