Try this: <script type="text/javascript"> $(document).ready(function(){ $("a#clickme").click(function(){ alert("You are now leaving the site."); });
$("a#hideme").click(function(e){ e.preventDefault(); $(this).hide(); }); }); </script> Your main problem was that document.ready was not closed properly. In the second example it shows how you should do a "return false", which I assume you did to stop the clicking moving the page to top. On Jan 30, 8:33 am, surreal5335 <surrea...@hotmail.com> wrote: > I am going over a tutorial on this site and trying to figure out whats > wrong with the syntax. The code I have is: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml"> > > <head> > <title></title> > <script type="text/javascript" > src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/ > jquery.min.js"></script> > > <script type="text/javascript"> > > $(document).ready(function(){ > > $("a").filter("#clickme").click(function(){ > alert("You are now leaving the site."); > }); > .end() > $("a").filter("#hideme").click(function(){ > $(this).hide(); > return false; > }); > .end(); > > </script> > </head> > <body> > > <a href="http://google.com/" id="clickme">I give a message when you > leave</a> > <br><br> > <a href="http://yahoo.com/" id="hideme">Click me to hide!</a> > <br><br> > > </body> > </html> > > The tutorial orginally set it up to refer to the elments using class, > but I changed it to id and used the '#' in jquery to reference the > id's. Neither this nor the tutrials suggestion worked for me. Firebug > states there is a syntax error with the first > > .end() > > I have tried putting a semi colon thinking it should be ending a > statement but that didnt help. > > Any thoughts?