Try a "return false" instead of "event.preventDefault()"

Liam

Pitchwife 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.
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 270.13.113/2400 - Release Date: 09/28/09 05:51:00


Reply via email to