JQeuery .each() in IE7 and IE8, Object doesn't support this property or method
<p>I have a complex legacy application that I'm trying to "theme" a bit after the fact, it loads an ASPX page which loads the application framework; in an <code>iframe</code> the "application" is loaded (a separate aspx).</p>

<p>In the application every <code>Panel</code> object is a <code>div</code> with an id of <code>PNLxxxxx</code> with x being arbitrary. Each of these sides of the house reference their own version of the jQuery library and it works in most browsers. When I hit compatibility mode on IE9 it then does not work, if I "step through" the errors the jQuery code runs and appears to work properly.</p>

<p>The errors are occuring in the <code>.each()</code> function of jQuery, I can empty it completely and still receive the errors. I removed most of the code from the loop (it still errors) to show:</p>

<pre><code>   $j(document).find("div[id^='PNL']").each(function(i) {
        $j(this).css("position", "relative");
    });      
</code></pre>

<p>The errors received are:
<code>Object doesn't support this property or method (Line3:12321)
'1' is null or not an Object (Line3:12386)
... etc.</code></p>

<p>I assume it's not able to reference the items retrieved with the <code>.find()</code> call. The strange thing is that if I run the same code in the Javascript Console in the IE debugger while in Compatibility mode it runs properly.</p>

<p>I've tried placing this in the application side with <code>$j(document).ready(function() {</code> and also at the end of the document on the application side.</p>

<p>I then tried placing it in the framework side with a call_out to check when the last <code>div</code> on the application page is loaded and referencing through the <code>iframe</code> (of which there is one) (<code>$j("iframe").contents().find("div[id='PNL']").each(function(i) {</code> )</p>

<p>When I trace the code back with the debugger it goes straight back to that <code>.each()</code> call. I know I can likely bypass the errors by coding by hand for each element but that seems a bit absurd. Any ideas?</p>
