I’m trying to create a function with jQuery in order to loop through each <td> in a table, when there are several tables in the page with no specific ids.
I understand how to loop through all td elements in a table, even when table id is passed, but I can’t get it to work when the function, which is triggered by one of the child <td> elements, has to use the parent table.
I’ve tried something (very silly) like
var tbl = $(this).closest('table');
$(tbl+" <td>").each(function() {
But ofcourse this doens’t work at all.
I can generate ids to make things easier but I’m sure there’s a way to do it more elegantly only with jQuery.
Try this instead