Having the following structure:
<td class="padding_right padding_left">Neighborhood</td>
<td>
<div id="neighborhoods_region">
<select class="inputs_form_data" id="neighborhood_id2" name="neighborhood_id2">
<option value=""></option>
<option value=""></option>
</select>
</div>
</td>
<td width="10%"><a class='delete-region'>remover</a></td>
I'm trying to when the remove link is clicked, to get the id number of the select id. In this case, I need to get the number 2 from the "neighborhood_id2".
But first I just trying to get the full id. neighborhood_id2 with the following code:
$(document.body).on('click','a.delete-region', function () {
alert($(this).closest('select').attr("id"));
});
but this returns me undefined.
note: the id number is generated on-the-fly on a dynamic form. So I may have neighborhood_id3 and so on.