Using jQuery to get the next or previous element from a selection
<p>How can I get the previous or next element from a jQuery selection?</p>

<p>Basically, I will have a set of elements, say all inputs:</p>

<pre><code>$('input')
</code></pre>

<p>When I have a single input, I also need to get the previous and next input.
Something like:</p>

<pre><code>$(this).prev('input')
$(this).next('input')
</code></pre>

<p>However, the inputs are not siblings and I don't want just the next DOM element. I want the next element in the jQuery selection (inputs in this case).</p>

<p><BR>I know I can iterate through a jQuery selection with</p>

<pre><code>.each(function(...
</code></pre>

<p>But I don't need to go over all of the elements, just the one before and after.</p>

<p>The elements will also be dynamically ordered (using jQuery UI sortables). </p>
