Determine the number of elements in a variable
<p>If i have a js variable that contains some html tags, how can I determine the number of tags inside the variable? Something like this:</p>

<pre><code>contents = "&lt;p&gt;something&lt;/p&gt;&lt;p&gt;something else&lt;/p&gt;";
$(contents).find("p").length &gt; 2;
</code></pre>

<p>Basically, I'm doing a <code>$(".someClass").each()</code> and iterating through a bunch of elements - when I encounter a <code>&lt;p&gt;</code> tag I'm putting it in the variable with .html() and now I need to know whats inside the variable to make another decision but my approach above isn't working. </p>
