Oh and here are the docs that apply:
http://docs.jquery.com/Events/bind#typedatafn

--
Brandon Aaron

On 9/27/07, Brandon Aaron <[EMAIL PROTECTED]> wrote:
>
> The click event on an A tag has a default action associated with it by the
> browser ... more specifically a redirect to the links href. You have to stop
> this default action in order to see your alert. There are two ways to do
> this.
>
> The first way: A click handler can return false to prevent the default
> (and stop propagation). To do this, your event handler would look like this:
>
> $("a").click(function(){
>     alert("Thanks for visiting!");
>     return false;
> });
>
> The second way: The event handler gets passed the event object as its
> first argument and the event object has a method to prevent the default
> behavior as well. You could also do the above like this:
>
> $("a").click(function(event){
>     alert("Thanks for visiting!");
>     event.preventDefault();
> });
>
> Hope that helps!
>
> --
> Brandon Aaron
>
>
> On 9/27/07, cmbtrx < [EMAIL PROTECTED]> wrote:
> >
> >
> > lol, wow--I sure was peeved!
> >
> > Uh anyway sorry, the page itself is off-limits (per my client's
> > request), but here's the code:
> >
> > <!DOCTYPE HTML PUBLIC
> > "-//W3C//DTD HTML 4.01//EN"
> > "http://www.w3.org/TR/html4/strict.dtd";>
> > <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
> > <head>
> > <title>test</title>
> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> > <meta name="title" content="" />
> > <meta name="description" content="" />
> > <meta name="keywords" content="" />
> > <link rel="stylesheet" href=" style.css" type="text/css" />
> > <script src="jquery.js" type="text/javascript"></script>
> > <script type="text/javascript">
> > $(document).ready(function(){
> >
> >         $("a").click(function(){
> >            alert("Thanks for visiting!");
> >          });
> >
> > });
> > </script>
> > </head>
> > <body><a name="top"></a>
> >
> > <a href="http://jquery.com/";>jQuery</a>
> >
> > [more html...]
> >
> >
> > So, if I understand this, clicking on the "jQuery" link above
> > should...uhh, pop an alert right? Or is jQuery really not that simple?
> > Or do I have a typo? Or am I in the wrong profession? (OK, don't
> > answer that.)
> >
> > And thanks for the amazing display of patience, people! (most other
> > code forums would have had me tarred and feathered by now!)
> >
> >
> > On Sep 27, 11:44 am, cmbtrx <[EMAIL PROTECTED]> wrote:
> > > OK, forgive my tone here...I'm actually quite flabbergasted.
> > >
> > > I ***FINALLY*** get around to trying out jquery.
> > >
> > > Oh, I'm sure that quite obviously I'm doing something wrong, because
> > > after following the first few paragraphs of the "How JQuery Works"
> > > section (clicking a link launches an alert box...uh ok, no fine) it
> > > does absolutely nothing.
> > >
> > > Wow.
> > >
> > > So far the javascript skills required for testing this are sub-fetal
> > > so I can't imagine what black magic I might possibly have introduced
> > > into this 79Kb albatross.
> > >
> > > No, OK, I won't condemn it yet, but can somebody enlighten me?
> > >
> > > (I thought this would be easy.)
> >
> >
>

Reply via email to