JS: get the closest id number
<p>Having the following structure:</p>

<pre><code>&lt;td class="padding_right padding_left"&gt;Neighborhood&lt;/td&gt;
&lt;td&gt;
    &lt;div id="neighborhoods_region"&gt;    
    &lt;select class="inputs_form_data" id="neighborhood_id2" name="neighborhood_id2"&gt;
        &lt;option value=""&gt;&lt;/option&gt;
        &lt;option value=""&gt;&lt;/option&gt;
    &lt;/select&gt;
    &lt;/div&gt;
&lt;/td&gt;
&lt;td width="10%"&gt;&lt;a class='delete-region'&gt;remover&lt;/a&gt;&lt;/td&gt;​
</code></pre>

<p>I'm trying to when the <code>remove</code> 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".</p>

<p>But first I just trying to get the full id. <code>neighborhood_id2</code> with the following code:</p>

<pre><code>$(document.body).on('click','a.delete-region', function () {
    alert($(this).closest('select').attr("id"));
});
</code></pre>

<p>but this returns me <code>undefined</code>.</p>

<p>note: the <code>id</code> number is generated on-the-fly on a dynamic form. So I may have <code>neighborhood_id3</code> and so on.</p>
