Get the number from the element's id
<p>I have some inputs as below:</p>

<pre><code>&lt;input type="hidden" id="selected_id-1" name="id[]" /&gt;
&lt;input type="hidden" id="selected_id-2" name="id[]" /&gt;
&lt;input type="hidden" id="selected_id-3" name="id[]" /&gt;
&lt;input type="hidden" id="selected_id-5" name="id[]" /&gt;
</code></pre>

<p>The list can contain more than just 4 elements.</p>

<p>So, I would like to extract the highest number (in our case = 5) from the ids of elements named "id".</p>

<p>Pure JavaScript needed.</p>

<p><strong>EDIT:</strong> Thank you everybody who answered my question.</p>
