Try using: return false; Instead of: event.preventDefault();
On Sep 28, 11:21 am, Pitchwife <dandau...@gmail.com> wrote: > Hello all, > > I'm trying to run through the simplest tutorials on jquery and for > some reason I can't get any of the jquery code to work. > > I've downloaded jquery and I've made sure that this file is in the > same directory as jquery-1.3.2.js. > > This is the code taken from the tutorial: > > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> > <script src="jquery-1.3.2.js" type="text/javascript"></script> > <script type="text/javascript"> > $(document).ready(function(){ > $("a").click(function(event){ > alert("As you can see, the link no longer took you to > jquery.com"); > event.preventDefault(); > }); > }); > > </script> > </head> > <body> > <a href="http://jquery.com/">jQuery</a> > </body> > </html> > > when the user clicks on the link it shouldn't take them to jquery.com, > instead it should display an alert box. > but it takes me to jquery.com every time. > > Thanks.