From this code, once you pressed the button, it will generate a new table row with 16 cells. I came up with the ideal ID for each cell, in the pattern of 'RxCx', and I'd like to ask everyone what code's still missing to let it be each cell's ID?
Thanks a lot for your help!
const tab = document.getElementById("tab");
const btn1 = document.getElementById("btn1");
var rowCount = 0;
var cellCount = 0;
btn1.addEventListener('click', () => {
var row = tab.insertRow(-1);
rowCount++;
for (var i = 0; i <= 15; i++) {
row.insertCell(i);
cellCount = i + 1;
var ID = "";
ID = ID + "R" + rowCount + "C" + cellCount;
console.log(ID);
}
});
<body>
<button id="btn1">Add</button>
<table id="tab"></table>
</body>