JavaScripture
Contribute via GitHub Feedback

JavaScript Event : Object

Event contains information describing the current event such as a click or download event. It is the first parameter to event listener callbacks. See MouseEvent, KeyboardEvent, and ProgressEvent for some derivations of Event.

Constructors

new Event(type : String, [eventInit : Object]) : Event
eventInit : {
bubblesBoolean
cancelableBoolean
}

Creates a new Event. Use dispatchEvent() to fire the event.

Example:

Run

Results:

 

Instance Properties

bubbles : Boolean  

Returns true if the event will bubble up through the ancestor hierarchy.

cancelable : Boolean  

Returns true if the event can be canceled (by calling preventDefault()).

currentTarget : Object  

The Object that the current callback is running for. This will be the element that registered the listener and will different than target if this event is in the bubble or capture phase.

Example:

Run

Results:

 

defaultPrevented : Boolean  

Returns true if preventDefault() has been called on this.

Example:

Run

Results:

 

eventPhase : Number  

The current phase of the event. Will be one of NONE, CAPTURING_PHASE, AT_TARGET, or BUBBLING_PHASE.

Example:

Run

Results:

 

isTrusted : Boolean  

target : Object  

The Object that originated this event. See also currentTarget.

Example:

Run

Results:

 

timeStamp : Number  

The time (in milliseconds since 01 January, 1970 UTC) that the event fired. Use Date to convert to a human readable time.

Example:

Run

Results:

 

type : String  

A string describing the type of event.

Example:

Run

Results:

 

Instance Methods

preventDefault() : undefined

Stops the browser's default behavior from running for the current event. Only cancelable events can have their default behavior prevented. See also stopPropagation() and stopImmediatePropagation().

Example:

Run

Results:

 

stopImmediatePropagation() : undefined

Stops other event listeners on this node and on other nodes in the event route from running. See also stopPropagation() and and preventDefault().

Example:

Run

Results:

 

stopPropagation() : undefined

Stops event listeners on other nodes in the event route from running. Other listeners attached to currentTarget will still run. See also stopImmediatePropagation() and preventDefault().

Example:

Run

Results:

 

Event Properties

AT_TARGET : Number  

Returned by eventPhase when at the target that originated the event.

BUBBLING_PHASE : Number  

Returned by eventPhase during the bubbling phase of the event route.

CAPTURING_PHASE : Number  

Returned by eventPhase during the capture phase of the event route.

NONE : Number  

Returned by eventPhase before the event is routed.