jQuery .ready() automatically defining variables for each element with ID in DOM
<p>I have noticed some unexpected behaviour when using the jQuery <code>.ready()</code> function, whereby afterwards you can reference an element in the DOM simply by using its ID without prior definition:</p>

<pre><code>&lt;html&gt;
&lt;script src="jquery.js"&gt;&lt;/script&gt;
&lt;script&gt;
        $(document).ready(function() {
                myowndiv.innerHTML = 'wow!'
        });
&lt;/script&gt;
&lt;body&gt;
        &lt;div id="myowndiv"&gt;&lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>

<p>I would have expected to have to declare and assign <code>myowndiv</code> with <code>document.getElementById("myowndiv");</code> or <code>$("#myowndiv");</code> before I could call <code>innerHTML</code> or anything else on it?</p>

<p>Is this behaviour by design?  Can anyone explain why?  My fear is that if I don't notice and refactor and end up not using <code>.ready()</code> or even using jQuery at all then my code will fail to execute with lots of <code>undefined</code> errors.</p>

<p>Cheers!</p>
