$( 'td:first-child', $( this ).parents ( 'tr' ) ).html ();
This will select the first TD element (:first-child filter) in the parent TR of the image. parents()
returns all parents of the element, and we filter the parents so that only TR elements are returned.
Also try writing your image like so:
<img src="bobsmith.png" onclick="doSomething(this)" />
and your function like so:
function doSomething ( imgEl ) {
}
and use imgEl
instead of this