JSFiddle - React, Tailwind, and code Playground
HTML
<table id=table>
<col />
<col span="2" />
<col id="col-c" />
<tr>
<td>a</td><td colspan="2">b</td><td id=c>c</td>
</tr>
</table>
<div id=log></div>
JavaScript
function getElementColumn(td)
{
var col = 0;
$(td).parent().find('> td, > th').each(function() {
if (this === td) return false;
col += +$(this).attr('colspan') || 1;
});
return col;
}
function getCol(table, colNumber)
{
var col = 0, elem;
$(table).find('> colgroup > col').each(function() {
if (colNumber == col) {
elem = this;
return false;
}
col += +$(this).attr('span') || 1;
});
return elem;
}
var colNumber = getElementColumn(document.getElementById('c'));
$('#log').append('<div>colNumber: ' + colNumber + '</div>');
var col = getCol(document.getElementById('table'), colNumber);
$('#log').append('<div>col: ' + col.id + '</div>');