how do i select the previous li using jquery?
<p>I have an unordered list, but there are headers within it for different categories.</p>

<pre><code>&lt;ul&gt;
    &lt;h2&gt;header1&lt;/h2&gt;
    &lt;li&gt;...&lt;/li&gt;
    &lt;li&gt;...&lt;/li&gt;
    &lt;li&gt;...&lt;/li&gt;
    &lt;li&gt;...&lt;/li&gt;
    &lt;h2&gt;header2&lt;/h2&gt;
    &lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>I'm trying to loop through them and order them by the date, but the headers are throwing it off.</p>

<p>I'm looping through using:</p>

<pre><code>var list = $('#articleList');
list.children("li").each(function () {
    ...
}
</code></pre>

<p>and I'm using this within the loop to select the one before it:</p>

<pre><code>var prev = $(this).prev("li");
</code></pre>

<p>For some reason, prev selects the headers if you are on the list item after the header instead of the list item before them. So my sorting ends up being correct within the headers, but I need the whole thing to be ordered, not just in sections.</p>
