问题描述:

so i have a list of addresses each with edit links and i want to grab the ID of the input within the list item

<li class="last">

<div class="checkout-select-address"><input type="radio" name="checkout_selected_address" id="checkout_selected_address_3" value="" /></div>

<div class="checkout-select-address-details">

<p><label for="checkout_selected_address_3">(Mothers)</label> <a href="#" title="Edit Address" class="edit-link right">Edit Address</a></p>

<input type="hidden" id="checkout_selected_address_3_name" value="" />

<input type="hidden" id="checkout_selected_address_3_title" value="" />

<input type="hidden" id="checkout_selected_address_3_first_name" value="" />

<input type="hidden" id="checkout_selected_address_3_last_name" value="" />

<input type="hidden" id="checkout_selected_address_3_address_line_1" value="" />

<input type="hidden" id="checkout_selected_address_3_address_line_2" value="" />

<input type="hidden" id="checkout_selected_address_3_address_line_3" value="" />

<input type="hidden" id="checkout_selected_address_3_town_city" value="" />

<input type="hidden" id="checkout_selected_address_3_county" value="" />

<input type="hidden" id="checkout_selected_address_3_postcode" value="" />

<input type="hidden" id="checkout_selected_address_3_country" value="" />

</div>

<div class="clear"></div>

so clicking on the link with class "edit-link" it will get the ID for the radio input within the li

Thanks in advance

网友答案:

try this :

$(".edit-link").click(function(){
   alert($(this).closest("li").find("input[type=radio]").attr("id"));
});

demo : http://jsfiddle.net/ZABBS/

相关阅读:
Top