Element listener supports a subset of the DOM's EventListener interface. It is used to declare event listeners and register them with specific nodes in the DOM.
Members Table
The following table lists the members exposed by the listener object.
The optional defaultAction attribute specifies whether after processing of all listeners for the event, the default action for the event (if any) should be performed or not.
Acceptable values:
Value
Description
cancel
if the event type is cancelable, the default action is cancelled
perform
the default action is performed (unless cancelled by other means, such as scripting, or by another listener).
event
true
The required event attribute specifies the event type for which the listener is being registered.
handler
true
The optional handler attribute specifies the URI reference of a resource that defines the action that should be performed if the event reaches the observer.
observer
true
The optional observer attribute specifies the id of the element with which the event listener is to be registered.
The optional propagate attribute specifies whether after processing all listeners at the current node, the event is allowed to continue on its path (either in the capture or the bubble phase).
Acceptable values:
Value
Description
stop
event propagation stops
continue
event propagation continues (unless stopped by other means, such as scripting, or by another listener).
target
true
The optional target attribute specifies the id of the target element of the event.
Property
Type
Readonly
Description
Method
Returns
Description
Event
B
C
Interface
Description
Pseudo-class
Description
Constant
Value
Description
Examlpes
In the given below example, the event click is prevented from propagation and an alert is called with message.