element

Event.element(event) -> Element

Returns the DOM element on which the event occurred.

Note that from v1.5.1, the element returned by Event.element is already extended.

Example

Here’s a simple code that lets you click everywhere on the page and, if you click directly on paragraphs, hides them.


Event.observe(document.body, 'click', function(event) {
  var element = Event.element(event);
  if ('P' == element.tagName)
    element.hide();
});

See also

There is a subtle distinction between this function and findElement.

Note for Prototype 1.5.0

Note that prior to version 1.5.1, if the browser does not support native DOM extensions (see this page for further details), the element returned by Event.element might very well not be extended. If you intend to use methods from Element.Methods on it, you need to wrap the call in the $() function like so:


Event.observe(document.body, 'click', function(event) {
  var element = $(Event.element(event));
  /* ...  */
});