jquery not working properly from js file
<p>I have the following jquery script to count characters in a box</p>

<pre><code>$('#myfield').keyup(function () {
    var left = 250 - $(this).val().length;
    if (left &lt; 0) {
        left = 0;
    }
    $('#counter').text('put: ' + left);
});
</code></pre>

<p>If i put this code right after the field it works, but i want to externalize this to a js file.. so i copy this in a myscript.js
and then do this:</p>

<pre><code> &lt;script language="JavaScript" type="text/javascript" src="script/myscript.js"&gt;&lt;/script&gt;
</code></pre>

<p>and it works... the problem is this call to myscript.js will only work if i declare it in that same spot after the field (which is at the bottom of the page).. but I want to include it at the top with all other js calls, if i do that, this won't work because I'll get a <strong>"'null' is null or not an object"</strong>.</p>

<p>So I tried enclosing it in document ready but even though I don't get an error nothing happens as in.. the function doesn't seem to be executed.</p>

<pre><code>$(document).ready(function(){
//function here
});
</code></pre>

<p>any suggestions?</p>
