Hello.

On 3/9/07, Abel Tamayo <[EMAIL PROTECTED]> wrote:
> Hi all. I'd like to know if there's a standard, easy way to determine with
> element triggered an event. I'm pretty sure there is, but can't find it in
> google. Maybe an atribute in the e parameter received by the function like:
>
> $("p").bind(
>   "click",
>   function(e){
>     console.log(e.TRIGGER); // This trigger attribute of the element e is
> the one that started the action.
>   }
> );
>
>
> So, is there an easy way?

Assuming you have an event handler attached to a container element,
you can find which one of its descendants triggered the action by
accesing the `target` property of the event.

So:

<p><strong>Strong</strong> and <em>emphasis</em> text.</p>

$("p").bind("cick", function(e) {
  alert(e.target.nodeName);
});

alerts the nodeName of the element you've clicked on.

For Spanish readers:
<http://blog.scriptia.net/articulos/2006/12/eventos-en-jquery.html>

HTH.
-- 
Choan
<http://choangalvez.nom.es/>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to