event.element() may not necessarily return $('object_id'). It returns the
element that fired the event, which can be a child element of
$('object_id').
For example:

Event.observe('document', 'click', function(event)
{
    console.log('You clicked on: ', event.element());
});

If you look at the console log, it will show the element you clicked on, not
the document.

As for speed, I would imagine that event.element() is faster than
$('object_id') because even.element() is just accessing a property, instead
of searching the dom for a node. But I could be wrong on this :)

-Hector


On Thu, Mar 26, 2009 at 2:54 PM, Dave L <dly...@gmail.com> wrote:

>
> Im wondering, what is the difference between the following:
>
> $('object_id').observe('click', function(event){
>    element = event.element()
> }
>
> VERSUS
>
> $('object_id').observe('click', function(event){
>    element = $('object_id)
> }
>
> Is there a difference in speed?  Is one better than the other in
> another way?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to