views:

2237

answers:

2

My page has an outside script that contains some jQuery. Most of it runs fine except this bit:

$(document).ready(function(){
    alert('x');         
});

That bit of code works fine when i run it inside the HTML page but not in the .js file. I have no other library in the HTML, i do have a window.onload inside the HTML but if i remove it, the jQuery bit still does not work. And it does not generate any error message.

Any suggestions?

+12  A: 

As this was the problem in this discussion, are you sure that you include jQuery before including your external script ?

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="externalScript.js"></script>
Wookai
A: 

Thank you. That was my problem. :D

Angoras
Cool... Could you mark my answer as accepted, so that people know that this problem has been solved ?Also, please note that you should not answer your own question, except to actually provide your own solution. Use comments instead.
Wookai