Right. Adding return false; stops the event bubbling and  the function
is called only once.
(and the selector should have been '#r1' - typo.)

Thx.
--Mike


On Dec 26, 9:55 pm, Shawn <[EMAIL PROTECTED]> wrote:
> Remember event bubbling is taking place for ALL events.
>
> I suspect you will need to stop the event propagation to resolve this
> issue.  This can be done one of two ways:
>
> 1) Return false from your click handler function.
> $("#r1").click(function () {
>    window.console.log("hello");
>    return false;
>
> });
>
> 2) call stopPropagation() method of the event object
> $("#r1").click(function (e) {
>    window.console.log("hello");
>    e.stopPropagation();
>
> });
>
> Also, in your sample code, you have $('r1').  There is no tags called
> "r1".  I suspect you meant $("#r1"), and that this is just a typo in
> your post.  But you might want to check that.. :)
>
> HTH
>
> Shawn
>
> Michael Nosal wrote:
> > If I have a div with a label and input in it:
> > <div id="tab">
> >   <input type="radio" id="r1" value="foo">
> >   <label for="r1">My Label</label>
> > </div>
>
> > and I add a click handler like so:
> > $('r1').click(function() {
> >   window.console.log("hello");
> > });
>
> > Clicking the div or the radio button gets one call to the click function.
> > Clicking the label element results in the click function being called twice.
> > Known? Unknown? Workaround?
> > Using jquery 1.2.1
>
> > --Mike N.

Reply via email to