This might help:

http://jquery.open2space.com/node/8

Also the rest of the howto's there may be of use for those just starting out.

Remember to change all file references to match the path and filenames on your system... :)

Shawn

kenny wrote:
Disclaimer: Complete jQuery/JavaScript noob here, but heavily
experienced developer overall. (And I have been googling around
finding similar questions, but nothing from those exchanges can get
this basic hello-world example working.)

Platform: FireFox 2.0.0.12 on Windows XP

Here is what I had after the first suggested enhancement, namely
adding an alert on a click:
<pre>
<html> <head>
   <script type="text/javascript" src="jquery.js"></script>
   <script type="text/
javascript">
      $(document).ready(function() {
         $("a").click(function() {
            alert("Hello world!");
         });
      });
   </script>
  </
head>
<body>
   <--- we will add our HTML content here -->
  </
body>
 </html>
</pre>

My first question is about the comment in the instructions that says:
"This should show the alert as soon as you click on the link.". I do
not see any link. No big deal, I added one.

My next question is simply that once I do add a link:

<pre>
<html> <head>
   <script type="text/javascript" src="jquery.js"></script>
   <script type="text/
javascript">
     $(document).ready(function() {
                        $("a").click(function() {
                           alert("Hello world!");
                           });
                        });
   </script>
  </
head>
<body>
   <--- we will add our HTML content here -->
   <a href="">nowhere</a>
  </
body>
 </html>
</pre>

... I still do not get an alert.

I do get an alert if I add the suggested alternative:

<pre>
   <a href="" onclick="alert('Hello world')">Link</a>
</pre>

...and then click on the link, so that much is working.

I ended up on this tutorial after experiencing the same thing on the
"How jQuery Works" tutorial, by the way.

Any help appreciated.

Reply via email to