My HTML table features cells that I want to highlight when clicked using CSS, but only until another cell is clicked.
I initially tried setting focus for the clicked cell and applying CSS styles based on focus, however this approach did not work as intended.
This is my current code:
$('td').click(function (event) {
//$(this).tabindex = 0;
//$(this).tabindex = 1;
$(this).focus();
});
And here is the corresponding CSS:
td:focus
{
background-color:Blue;
}
I suspect that adding a class to td
might be problematic since I would need to remove the class when another cell is clicked. I am seeking assistance in achieving my goal and exploring other possible solutions or workarounds.