I am trying to get the value of first td in each tr when a users clicks \"click\".
The result below will output aa ,ee or ii. I was thinking about using closest(\'t
$(".hit").click(function(){ var values = []; var table = $(this).closest("table"); table.find("tr").each(function() { values.push($(this).find("td:first").html()); }); alert(values); });
You should avoid $(".hit") it's really inefficient. Try using event delegation instead.
$(".hit")