On Feb 3, 2008, at 7:47 AM, Sathya wrote:


Hi,
Am new to jquery and also not so proficient with . So bear with me if
it sounds silly.  I just can't get jquery to work the way its
promised.

I did these,
1. Downloaded jquery-1.2.js

2. Included it in my html. And wrote my first code as this
${document}.ready(function() {
   ${'a'}.click(function() {
       alert("Link clicked");
       ${'#main-content'}.html('<h1> Hello </h1>');
       return false;
   })
});
This didnt work. I got an error that said "missing ; before statement"

3. Changed my code to replace all ${} references with jQuery(). Though
this works, I get two alerts everytime i click a link. And content of
div with id main-content doesn't change either.

What am I doing wrong. Any help/pointer will be appreciated.

From the error message, it looks like you are missing a semicolon. Try this:

${document}.ready(function() {
   ${'a'}.click(function() {
       alert("Link clicked");
       ${'#main-content'}.html('<h1> Hello </h1>');
       return false;
   }); // <--- added semicolon
});

If you still get an error, let us know and perhaps provide a link to the page that is experiencing the problem. This is a very basic script that has proven to work on countless other sites, so it shouldn't be too hard to detect what might be going wrong.

--Karl Swedberg

Reply via email to