$(function () {
$('td').on('click', function () {
var $td = $(this),
$tr = $td.parent();
alert('row: ' + $tr.index() + ', col: ' + $td.index());
});
});
document.addEventListener("DOMContentLoaded", () => {
let tab = document.getElementById("tab");
tab.onclick = e => {
let cell = e.target;
let row = cell.parentElement;
let rows = row.parentElement.children;
for (var i = 0; i < rows.length; ++i) {
if (rows[i] === row) {
break;
}
}
let columns = row.children;
for (var j = 0; j < columns.length; ++j) {
if (columns[j] === cell) {
break;
}
}
alert('Row: ' + i + ', Column: ' + j);
};
});