I have an onclick function attached to each <td> element. The function needs to know the placement in the table (row and column).
I found an attribute called rowIndex for <tr>s, but that would involve getting the parent element and still doesn’t help with column number.
Here is my function so far (it’s within a loop, so it’s attaching to every td)
td.onclick = function(event) {
event = (event) ? event : window.event;
console.log('rowIndex, colIndex');
}
I could figure this out with jQuery, but I’m trying to do without.
My first thoughts were:
JS Fiddle demo.
This was then refined to:
JS Fiddle demo.