<tr >
<td>
opel
</td>
<td>mazda</td>
<td>audi</td>
</tr>
document.querySelector('table').addEventListener('click', e => {
const td = e.target.closest('td');
if (td) {
const index = td.cellIndex;
console.log(index);
}
});