I\'ve used JQuery to add a \"image\" button to a few rows in a table. I used the following code:
$(\"#tblResults tr:nth-child(1) td.ResultsHeader span.gridRC
Ok so if an image in a table is clicked you want the data of the first row of the table this image is in.
//image click stuff here {
$(this). // our image
closest('table'). // Go upwards through our parents untill we hit the table
children('tr:first'); // Select the first row we find
var $row = $(this).closest('table').children('tr:first');
parent()
will only get the direct parent, closest
should do what we want here.
From jQuery docs: Get the first ancestor element that matches the selector, beginning at the current element and progressing up through the DOM tree.