EventTarget

  • Revision slug: DOM/EventTarget
  • Revision title: EventTarget
  • Revision id: 308291
  • Created:
  • Creator: MattBrubeck
  • Is current revision? No
  • Comment fix links

Revision Content

{{ DomRef() }}

An EventTarget is a DOM interface implemented by objects that can receive DOM events and have listeners for them. The most common EventTargets are DOM elements, although other objects can be EventTargets too, for example document, window, XMLHttpRequest, and others.

Methods

Name & Description Return
addEventListener( type, handler, bubble )
Register an event handler of a specific event type on the EventTarget.
-
removeEventListener( type, handler )
Removes an event listener from the EventTarget.
-
dispatchEvent( event )
Dispatch an event to this EventTarget.
Boolean

Specification

DOM Level 2 Events: EventTarget

Revision Source

<p>{{ DomRef() }}</p>
<p>An <code>EventTarget</code> is a DOM interface implemented by objects that can receive DOM events and have listeners for them. The most common <code>EventTarget</code>s are <a href="/en-US/docs/DOM/element">DOM elements</a>, although other objects can be <code>EventTarget</code>s too, for example <a href="/en-US/docs/DOM/document">document</a>, <a href="/en-US/docs/DOM/window">window</a>, <a href="/en-US/docs/XMLHttpRequest">XMLHttpRequest</a>, and others.</p>
<h3 id="Methods" name="Methods">Methods</h3>
<table class="fullwidth-table">
  <tbody>
    <tr>
      <th>Name &amp; Description</th>
      <th>Return</th>
    </tr>
    <tr>
      <td><code><a href="en/DOM/element.addEventListener">addEventListener</a>( <a href="en/Core_JavaScript_1.5_Reference/Global_Objects/String">type</a>, <a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Function">handler</a>, <a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">bubble</a> )</code><br />
        Register an event handler of a specific event type on the <code>EventTarget</code>.</td>
      <td>-</td>
    </tr>
    <tr>
      <td><code><a href="en/DOM/element.removeEventListener">removeEventListener</a>( <a href="en/Core_JavaScript_1.5_Reference/Global_Objects/String">type</a>, <a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Function">handler</a> )</code><br />
        Removes an event listener from the <code>EventTarget</code>.</td>
      <td>-</td>
    </tr>
    <tr>
    </tr>
    <tr>
      <td><code><a href="en/DOM/element.dispatchEvent">dispatchEvent</a>( <a href="en/DOM/event">event</a> )</code><br />
        Dispatch an event to this <code>EventTarget</code>.</td>
      <td><a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">Boolean</a></td>
    </tr>
  </tbody>
</table>
<h3 id="Specification" name="Specification">Specification</h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget">DOM Level 2 Events: EventTarget</a></p>
Revert to this revision