JSFiddle - React, Tailwind, and code Playground
HTML
<input type="button" value="Generate a table." onclick="CreateTable()">
<br />
<button onclick="addImage(prompt('Insert field'))">Add rook</button>
<button onclick="addImage(prompt('Insert field'))">Add knight</button>
<div id="space">
</div>
JavaScript
function CreateTable(){
var poz = document.getElementById('space');
// createing table adn inserting into document
tab = document.createElement('table');
poz.appendChild(tab);
tab.border = '5';
for (var i = 0; i < 8; i++){
// creating row and inserting into document
var row = tab.insertRow(i);
for(var j = 0; j < 8; j++){
// creating cells and fill with data (numbers)
var cell = row.insertCell(j);
// cell.innerHTML = idStr;
// cell.id = idStr;
cell.innerHTML = String.fromCharCode(65 + i) + (j + 1);
if((i+j)%2){cell.style.backgroundColor = 'silver';}
else{cell.style.backgroundColor = '#00f';}
cell.style.height = '50px';
cell.style.width = '50px';
cell.style.color = 'white';
cell.style.textAlign = 'center';
};
};
}
function updateRow(idStr){
cell = document.getElementById(idStr);
if(cell != null){
cell.style.backgroundColor = 'red';
}
}
// CreateTable()