I think the OP does want it to follow the link, but show the alert first ?

So "return false" is not required.

OP - make sure jQuery is loading (there's no error if it doesn't). Try just an alert message within $(document).ready() itself.



Steve wrote:
Hi,

You need to return false so the anchor tag does not behave in its
normal way (ie, take you to the link specified).

So this should work:

$("a").click(function(event){
    alert("Thanks for visiting!");
    return false;
  });


On Apr 2, 9:47 pm, "Mohd.Tareq" <tareq.m...@gmail.com> wrote:
On Fri, Apr 3, 2009 at 5:52 AM, yrstruly <anthony.apol...@gmail.com> wrote:

Hallo
Im new to jQuery. I have donwloaded the jquery-1.3.2min file and i
have copied that introduction code from the website and saved it in
the same directory as the jquery file. When i run the script it seems
to be working and when i click on the link it goes to the website, but
isnt this script suppose to show an alert message first, before it
goes to the website?
Please what am i doing wrong? Have a saved it correctly or is the file
i donwloaded not valid? Please help. The code follows:
<!DOCTYPE html>
 <html lang="en">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
   $(document).ready(function(){
  $("a").click(function(event){
    alert("Thanks for visiting!");
  });
 });
</script>
 </head>
 <body>
  <a href="http://jquery.com/";>jQuery</a>
 </body>
 </html>
=================== ===================Go for this script you can see now ur
click function will execute first & then it will go for link

<!DOCTYPE html>
 <html lang="en">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <script type="text/javascript" src="jquery.js"></script>

  <script type="text/javascript">
   $(document).ready(function(){
  $("a").click(function(event){
    window.href="http://jquery.com/";; <http://jquery.com/>
    alert("Thanks for visiting!");
    return true;
  });
 });

  </script>
 </head>
 <body>
  <a href="# <http://jquery.com/>">jQuery</a>
 </body>
 </html>

cheers.

Ragx
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.0.238 / Virus Database: 270.11.40/2039 - Release Date: 04/03/09 06:19:00


Reply via email to