Using jQuery, how can I find the column index of an arbitrary table cell in the example table below, such that cells spanning multiple columns have multiple indexes?
There is a more concise answer here: Get Index of a td considering the colspan using jquery
In short:
var index = 0; $("#example2").prevAll("td").each(function() { index += this.colSpan; }); console.log(index);