JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tbody id='moron'>
<tr>
<th>1x1</th>
<th>1x2</th>
<th rowspan="6">1x3</th>
<th>1x4</th>
</tr>
<tr>
<th colspan="2">2x1</th>
<th>2x4</th>
</tr>
<tr>
<th>3x1</th>
<th>3x2</th>
<th rowspan="3">3x4</th>
</tr>
<tr>
<th>4x1</th>
<th>4x2</th>
</tr>
<tr>
<th>5x1</th>
<th>5x2</th>
</tr>
<tr>
<th colspan="2">6x1</th>
<th>6x4</th>
</tr>
</tbody>
</table>
<input type="text" id="x" value="х координата"><input type="text" id="y" value="y координата">
<div id='colored'>ПОКРАСИТЬ!</div>
CSS
table{
border-collapse: collapse;
}
th{
width: 50px; height: 25px;
border: 1px solid black;
}
#colored{
color: white;
background: red;
}
JavaScript
function CoordObject(idTable){
this.table = document.getElementById(idTable);
for(var i1=0;i1<this.table.children.length; i1++){
var tr = this.table.children[i1];
for(var i2=0;i2<tr.children.length; i2++){
var i4 = i2;
var that = this;
if(tr.children[i2].hasAttribute('rowspan') == true){
check();
var rowspan = tr.children[i2].getAttribute('rowspan');
for(var i3=0;i3<rowspan; i3++){
this[(i1+i3+1)+'x'+(i4+1)] = tr.children[i2];
}
}
if(tr.children[i2].hasAttribute('colspan') == true){
var colspan = tr.children[i2].getAttribute('colspan');
for(var i3=0; i3<colspan; i3++){
this[(i1+1)+'x'+(i2+i3+1)] = tr.children[i2];
}
}
if(tr.children[i2].hasAttribute('colspan') != true && tr.children[i2].hasAttribute('rowspan') != true){
check();
}
function check(){
if((i1+1)+'x'+(i4+1) in that){
i4++;
check();
}else{
that[(i1+1)+'x'+(i4+1)] = tr.children[i2];
}
}
}
}
}
var myObj = new CoordObject('moron');
document.getElementById('colored').onclick = function(){
var x = document.getElementById('x').value;
var y = document.getElementById('y').value;
myObj[x+'x'+y].style.background = 'red';
}