The name of the closest function is extremely misleading: it is actually the closest ancestor that returns.
The correct code is:
var value = $(this).parent().siblings('td').children('input').val();
I would not recommend attaching an event handler to alllllllll anchor tags; this will be ineffective if there are several elements on the page. Instead, I would highly recommend use delegate () or live () instead.
$('#objects').delegate('a.delete', 'click', function (e) { e.preventDefault(); var val = $(this).parent('td').siblings('td').find('input').attr('value'); alert(val); });
This will attach the event handler to the table (once), and then use the JavaScripts bubbling mechanisms to detect clicks on the elements that match the selector passed in the first argument (in this case, your delete buttons).
source share