jQuery not working straight away : <p>I am working on Ruby on Rails and a simple jQuery won´t execute over an element like this:</p>

<pre><code>$("header").hide();
</code></pre>

<p>However, if i wrap it into a function and call it with document.ready it does the right thing:</p>

<pre><code>function myCode() {
    $("header").hide();
}

$(document).ready(myCode);
</code></pre>

<p>Why it does not work straight forward?? I have installed gem jquery-rails and even have //=required jquery.min.js in the application.js file.</p>

<p>Thanks for the help!</p>
