I am trying to change the background color of a cell depending on my row
and col
id. I have tried like this but didn't work.
let rowNumber = 1;
let colNumber = 1;
document.getElementById("myTable").rows[rowNumber].cells.item(colNumber).style.backgroundColor = "red";
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table id="myTable"><tbody><tr><td>0-0</td><td>0-1</td><td>0-2</td></tr><tr><td>1-0</td><td>1-1</td><td>1-2</td></tr><tr><td>2-0</td><td>2-1</td><td>2-2</td></tr></tbody></table>