JSFiddle - React, Tailwind, and code Playground
HTML
<table id="table">
<tr>
<td>
<strong>Northwest</strong>
...Metal..Silver..Elders...
</td>
<td>
<strong>Northwest</strong>
...Metal..Silver..Elders...
</td>
</tr>
</table>
CSS
table, td {
border: solid 1px gray;
padding: 1em;
}
.highlight {
background: yellow;
}
JavaScript
table.onclick = function(event) {
let target = event.target.closest('td')
if (target)
highlight(target)
}
var selectedTd;
function highlight(node) {
if (selectedTd) {
selectedTd.classList.remove('highlight');
}
selectedTd = node;
selectedTd.classList.add('highlight');
}