views:

98

answers:

2

Hi,
Whenever I try to load the following part in <head> tag on firfox browser, I get the message as $ is not define.

May I know the reason? I'm trying to load the jquery.js file before loading any custom script after CSS part.

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
A: 

Is jquery.js in the same directory as the page you are requesting? If $ is undefined, then the browser is NOT seeing jquery.js which means the file path is incorrect or the file is corrupt. Or, as Web Logic pointed out, $ can be overwritten by another library such as prototype.

E.g. does your document root look like this?

index.htm  (page you are loading perhaps)
jquery.js  (jquery)

Test: make sure you can access your jquery.js from the browser.. if you are accessing your page: www.yourdomain.com/index.htm

the you should be able to 'see' jquery the same way: www.yourdomain.com/jquery.js

Dan Heberden
+3  A: 
  • Are you specifying the correct path to jquery file, is it present in the same folder where you page is?
  • Are you using any other javascript library other than jquery?

Also this line is incomplete:

$(document).ready(function(){

Should be:

$(document).ready(function(){
   // your code here
});
Web Logic