views:

101

answers:

3

Hello, i have to learn JQuery. Here is the first sample from their tutorial:

<html>
  <head>
    <script type="text/javascript" src="jquery.js"></script>

    <script type="text/javascript">
    $(document).ready(function(){
                     alert("Thanks for visiting!");
             });

    </script>
  </head>
  <body>
    <a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;
  </body>
</html>

It doesn't work. After loading page i don't see any popups. I tried code:

 window.onload = function() { alert('...'); }

It works, but that example doesn't, why?

P.S. I've downloaded jquery and copied it to the current dir of page.

+1  A: 

The code looks fine. Make sure jquery.js is in the same directory as the html file, and is indeed named thus. So not jquery-1.3.2.js or something like that.

Aistina
A: 

I don't know that we will be able to provide a better answer. As written (as long as the jquery.js file is in the correct relative location) the code should execute as designed.

If you have doubts as to whether the script is pulling from the correct location you can use a CDN provided script so you know that it is actually pulling..

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
Quintin Robinson
A: 
<html>
  <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;

    <script type="text/javascript">
    $(document).ready(function(){
                     alert("Thanks for visiting!");
             });

    </script>
  </head>
  <body>
    <a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;
  </body>
</html>

This works for me. All I did differently was link the current versin of jQuery from the Google Ajax API library.

Give this a try.

idrumgood