JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<table id="tableId" border=1>
<tbody>
<tr><td>Item one</td></tr>
<tr><td>Item two</td></tr>
<tr><td>Item three</td></tr>
</tbody>
</table>
</div>
JavaScript
function addRowHandlers() {
var rows = document.getElementById("tableId").rows;
for (i = 0; i < rows.length; i++) {
rows[i].onclick = function(){ return function(){
var cell = this.cells[0];
var id = cell.innerHTML;
alert("id:" + id);
};}(rows[i]);
}
}
window.onload = addRowHandlers();