SO-73840608
by David Thomas
HTML
<button id="btn1">Add</button>
<table id="tab"></table>
CSS
td {
min-height: 1em;
min-width: 1em;
}
td[id]::before {
content: attr(id);
}
JavaScript
const tab = document.getElementById("tab");
const btn1 = document.getElementById("btn1");
btn1.addEventListener('click', () => {
let row = tab.insertRow(-1);
for (let i = 0; i <= 15; i++) {
let c = row.insertCell(i);
c.id = `R${++row.rowIndex}C${++c.cellIndex}`;
}
});