A couple of things:

1) the event.target is always a pointer to the element that spawned the
event. In this case, the actual element at the top of click event bubble -
the div.

2) if you want a pointer to the link you added the event to, guess what, you
already have one.

var link = $('link');
link.addEvent('click', function(){ $("debug").innerHTML = link.get('id');
});



On Wed, Aug 11, 2010 at 8:15 AM, Slik Jay <[email protected]> wrote:

> i guees, he meant how to make target = link (yes, this = link) when
> you clicking on divs
>
> On Wed, Aug 11, 2010 at 6:12 PM, Ryan Florence <[email protected]>
> wrote:
> > I'm not understanding what you want / expect to happen.
> >
> > Click one of he divs and the event fires.
> > Click the link, but not a div, and the event fires.
> >
> >> I want the event to be fired as if the link
> >> was clicked.
> >
> >
> > It does.  Perhaps you're looking for "this"?
> >
> > http://mootools.net/shell/29NC5/1/
> >
> >
> > On Aug 11, 2010, at 9:02 AM, batman42ca wrote:
> >
> >> I've been searching around for an answer but no luck so far.
> >>
> >> I have a link that contains various other elements. I create an event
> >> on the link, but clicking on the elements inside the link triggers the
> >> event, not on the link, but on the inner element I clicked. I guess
> >> that's event delegation in action but regardless of what element I
> >> clicked inside the link, I want the event to be fired as if the link
> >> was clicked.
> >>
> >> Here's the code: http://mootools.net/shell/29NC5/
> >>
> >> I would have thought that unless I do something to prevent it, the
> >> event should bubble up to the parent link. I'm not seeing that happen.
> >
> >
>

Reply via email to