Select specific closest element
问题 I have the following html : <table id="objects"> <tr> <td> <input type="text" value="2" /> </td> <td> <a href="#" class="delete">link</a> </td> </tr> <tr> <td> <input type="text" value="4" /> </td> <td> <a href="#" class="delete">link</a> </td> </tr> </table> When I click anchor tag I'd like to select <input> closest to my link, and get it's value. How can I do this ? I was trying : $('.delete').click(function(e){ e.preventDefault(); var val = $(this).closest('input').attr('value'); alert(val