jQuery.Event Constructor
The jQuery.Event
constructor is exposed and can be used when calling trigger. The new
operator is optional.
Check trigger's documentation to see how to combine it with your own event object.
Example:
1
2
3
4
5
|
var e = jQuery.Event( "click" );
jQuery( "body" ).trigger( e );
|
As of jQuery 1.6, you can also pass an object to jQuery.Event()
and its properties will be set on the newly created Event object.
Example:
1
2
3
4
5
|
var e = jQuery.Event( "keydown", { keyCode: 64 } );
jQuery( "body" ).trigger( e );
|
Event Properties
jQuery normalizes the following properties for cross-browser consistency:
-
target
-
relatedTarget
-
pageX
-
pageY
-
which
-
metaKey
The following properties are also copied to the event object, though some of their values may be undefined depending on the event:
altKey, bubbles, button, cancelable, charCode, clientX, clientY, ctrlKey, currentTarget, data, detail, eventPhase, metaKey, offsetX, offsetY, originalTarget, pageX, pageY, prevValue, relatedTarget, screenX, screenY, shiftKey, target, view, which
OtherProperties
Certain events may have properties specific to them. Those can be accessed as properties of the event.originalEvent
object.
Example:
1
2
3
|
jQuery.event.props.push( "dataTransfer" );
|