How to check for DOM equality with jQuery?
<p>I'm basically building a simple list, and one of the items in the list is selected. I'm accomplishing this by having a "selected" class applied to whichever item I want to have selected.  I have two buttons that go forward and backward which traverse this list.  However, when the user gets to the first or the last element in the list, I want to do a post back.  This is where I'm stuck, because I'm having trouble identifying that the currently selected item is not the first or the last.</p>

<p>Simple Example:</p>

<pre><code>&lt;div id="list"&gt;
    &lt;p&gt;item 1&lt;/p&gt;
    &lt;p&gt;item 2&lt;/p&gt;
    &lt;p class="selected"&gt;item 3&lt;/p&gt;
&lt;/div&gt;
</code></pre>

<p>Let's say the user presses the next button, at this point I'm checking for something similar to this:</p>

<pre><code>if (jQuery('#list p.selected') == jQuery('#list p:last-child'))
    //do post back
</code></pre>

<p>However, this logic is returning false, which leads me to believe I'm approaching this the wrong way.</p>

<p>What is the best way for me to check for this kind of logic using jQuery?</p>
