jQuery parsing raw HTML, and hasOwnProperty on Firefox
<p>I load up some HTML using <code>$.get</code> or <code>$.ajax</code>. In the debugger for both Chrome and Firefox i can see the html has been loaded properly:</p>

<p><strong>&gt; data</strong></p>

<pre><code>"&lt;html&gt;&lt;head&gt;&lt;title&gt;&lt;/title&gt;&lt;/head&gt;&lt;body&gt;
&lt;div id="topdiv" style="display:none;width:880px; height:600px;"&gt;&lt;/div&gt;
&lt;/body&lt;/html&gt;"
</code></pre>

<p>So it's a string of HTML. Great. Next I try to use jQuery to parse it:</p>

<p><code>$doc = $(data);</code></p>

<p><strong>&gt; $doc</strong></p>

<pre><code>[&lt;TextNode textContent="\n\n"&gt;, 
title, 
&lt;TextNode textContent="\n\n\n"&gt;, 
div#topdiv, 
&lt;TextNode textContent="\n \n"&gt;]
</code></pre>

<p>Whoah, what? Where did <code>html</code>, <code>head</code>, <code>body</code> go? OK, well anyway, all I care about is the div</p>

<p><code>$div = $data.find('div');</code></p>

<p><strong>&gt; $div</strong></p>

<p><code>[]</code></p>

<p>Huh??</p>

<p>OK. The div is empty. Upon further experimentation, I realize that jQuery basically ignores any top-level tags. Then it doesn't actually let you select any 2nd level tags, and so if there is a div nested inside the outer div, that WILL be selected. But... what??</p>

<p>Seems jQuery kind of chokes on those "TextNode" elements, that, curiously, it created itself (instead of html, body). So I wrote some code to get around this by looping through the elements, and extracting the non-text nodes directly:</p>

<pre><code>function getNodes($doc) {
    var result = new Array();
    for (var i = 0; i &lt; $doc.length; i++) {
        if ($doc[i].hasOwnProperty("tagName")) {
            result.push($doc[i]);
        }
    }
    return $(result);
}
</code></pre>

<p>Worked great! On Chrome.</p>

<p>Tried it in Firefox, and nothing works again.</p>

<p>Turns out that not every object in Firefox has a <code>hasOwnProperty</code> function. WHAT?? Ok. So rewrite to this:</p>

<p><code>typeof($tempHtml[i].tagName) !== 'undefined'</code></p>

<p>Finally, works in Firefox too.</p>

<p>Wow. Am I just being stupid? Why is so much post processing needed just to turn a string of HTML into a jQuery object? I feel like I must be missing something obvious. Is there a way to do this that does not involve such mayhem?</p>

<p>All I am trying to do is load up some HTML and turn it into a jQuery object. Yet it seems to be an increasingly baffling ordeal. Am I just doing something fundamentally wrong? Why is this so complicated?</p>
