How do I get the row and column number of the clicked table cell using jQuery, i.e.,
$("td").onClick(function(event){
var row = ...
var col = ...
});
How do I get the row and column number of the clicked table cell using jQuery, i.e.,
$("td").onClick(function(event){
var row = ...
var col = ...
});
its better to bind a click handler to the entire table and then use event.target to get the clicked TD. Thats all i can add to this as its 1:20am
Off the top of my head, one way would be to grab all previous elements and count them.
You can use the Core/index function in a given context, for example you can check the index of the TD in it's parent TR to get the column number, and you can check the TR index on the Table, to get the row number:
Check a running example here.
Can you output that data in the cells as you are creating the table?
so your table would look like this:
then it would be a simple matter
Get COLUMN INDEX on click:
Get ROW INDEX on click: