Function not loading on page
<p>Click event with jquery function is not working when it is before the a tag but it is working fine after the a tag. Also, if I use <code>document.ready</code> then it works. I would like to know why it is not working when it is before the a tag.</p>

<pre><code>&lt;head&gt;
    &lt;script type="text/javascript"&gt;
        function jchand(){
            $('a').click(function(){
                alert('a')
            })
        }
        jchand();
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;a href="#" &gt;click me&lt;/a&gt;
&lt;/body&gt;
</code></pre>
