Comparing DOM elements with jQuery
<p>I am working inside of a jQuery <code>each</code> iterator:</p>

<p><code>$('p').each(function(){ ... });</code></p>

<p>I'd like to create an expression that evaluates to true when:</p>

<ul>
<li><code>$(this)</code> is the last <code>p</code> element</li>
<li>scope is <code>$(this).parent()</code></li>
<li><code>$(this)</code> must be a direct child of <code>$(this).parent()</code></li>
<li><code>$(this)</code> is not necessarily the last direct child of <code>$(this).parent()</code></li>
</ul>

<p>Here are a few scenarios, with the desired <code>p</code> marked by asterisks:</p>

<pre><code>&lt;div&gt;
  &lt;p&gt;div1 p1&lt;/p&gt;
  &lt;p&gt;div1 p2&lt;/p&gt;
  &lt;p&gt;div1 p3***&lt;/p&gt;
&lt;/div&gt;

&lt;div&gt;
  &lt;p&gt;div2 p1***&lt;/p&gt;
  &lt;span&gt;div2 s1&lt;/span&gt;
&lt;/div&gt;

&lt;div&gt;
  &lt;p&gt;div3 p1***&lt;/p&gt;
  &lt;div&gt;
    div3 d1
    &lt;p&gt;div3 p2&lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I'd post my attempts at a solution, but there have been too many failed ones. Thanks for the help.</p>
