ok, lets load jQuery at the bottom. But I need it sooner than that:
<body> <div id="aaaa"></div> <script> $('#aaa').click FAIL </script> </body> <script src=jquery> Even if some people don't recommend it, I do recommend loading jQuery as the first script in your website. The jQuery plugins and stuff can go at the bottom of your document without problems if you add non-intrusive code after loading them.
Instead of loading at the bottom of the <body></body> part of the document, load it in the header:
<html> <head> <title>...</title> <script type="text/javascript" src="jquery_file.js"></script> <!-- ... --> </head> <body> <!-- ... --> <a href="#" id="aaa">Click me</a> <!-- ... --> <script type="text/javascript"> $('#aaa').click(function(e) { alert('Now this should work.'); }); </script> </body> </html> As a sidenote, please consider not including any script inside the <body> tag. jQuery is made to be, as I said before, non-intrusive, meaning it should not be mixed with the HTML. You're doing bad practices.
Your $('#aaa').click could (and should) be called in a script outside of the body tag itself and after importing jQuery. You could perfectly include that script tag just below the one that imports the jQuery library and it should work just fine.
<head></head>section?