How to use jQuery event
jQuery's methods for event
Method | Description |
---|---|
.bind() | Binds an event handler |
.delegate() | Binds a handler to one or more events currently or in the future |
.die() | Removes event handlers add using the .live() method |
.live() | Binds a handler currently or in the future |
.one() | Attaches an event handler that is executed at most once |
.proxy() | Takes a function and returns another belonging to a specifi ed context |
.trigger() | Executes event handlers attached to an element for an event type |
.triggerHandler() | Executes all handlers for a specifi c event |
.unbind() | Removes event bindings created with .bind() |
.undelegate() | Removes bindings created with .delegate() |
Event handler
jQuery event handlers.
- .blur()
- .focus()
- .select()
- .submit()
- .click()
- .dblclick()
- .focusin()
- .focusout()
- .hover()
- .mousedown()
- .mouseenter()
- .mousemove()
- .mouseout()
- .mouseover()
- .mouseup()
- .toggle()
- .error()
- .resize()
- .scroll()
Event object
The Event object passed into the handlers is normalized and is of the type jQuery.Event.
It contains the properties outlined in the following list:
Property | Description |
---|---|
altKey | true if the Alt key was pressed. |
attrChange | |
attrName | |
Bubbles | |
Button | |
Cancelable | |
charCode | |
Client | |
Client | |
ctrlKey | true if the Ctrl key was pressed. |
currentTarget | |
data | passed as the second parameter to the bind() command. |
detail | |
eventPhase | |
fromElement | |
handler | |
keyCode | For keyup and keydown events, returns the pressed key. |
layerX | |
layerY | |
metaKey | true if the Meta key was pressed. |
newValue | |
Offset | |
originalTarget | |
pageX | For mouse events, horizontal coordinate. |
pageY | For mouse events, vertical coordinate. |
prevValue | |
relatedNode | |
relatedTarget | For some mouse events, cursor left or entered when the event was triggered. |
Screen | |
screenX | For mouse events, horizontal coordinate. |
screenY | For mouse events, coordinate from the screen origin. |
shiftKey | Set to true if the Shift key was pressed. |
srcElement | |
target | |
toElement | |
View | |
wheelDelta | |
which |