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() |
jQuery event handlers.
- .blur()
- .focus()
- .select()
- .submit()
- .click()
- .dblclick()
- .focusin()
- .focusout()
- .hover()
- .mousedown()
- .mouseenter()
- .mousemove()
- .mouseout()
- .mouseover()
- .mouseup()
- .toggle()
- .error()
- .resize()
- .scroll()
The Event object passed into the handlers is normalized and is of the type jQuery.Event.
It contains the properties outlined in the follong 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 |
Home
JavaScript Book
jQuery
JavaScript Book
jQuery
Event:
- jQuery Event
- jQuery's methods for event
- Event object
- event.keycode
- event.clientX/clientY
- event.pageX/pageY: click event coordinates
- event.preventDefault()
- event.stopPropagation(): Stop only an event from bubbling by using the stopPropagation method.
- event.target.tagName
- event.which:check key code
- return false to Cancel a default action and prevent it from bubbling up
- bind
- .blur()
- .change()
- .click()
- .error()
- .dblclick()
- .delegate()
- die:Removes a bound live event
- .focus()
- .hover()
- keydown() event
- .keypress()
- keyup event and check the key code
- .live()
- .load()
- mousedown() event
- mouseenter() event
- mouseleave
- mousemove()
- mouseover() event
- mouseout
- mouseup() event
- .off() removes events
- .on() replaces the functionality of all the event methods.
- .one() method executes handler only once.
- .ready()
- .resize()
- .scroll()
- .select()
- .submit()
- .toggle()
- .trigger()
- .triggerHandler()
- .unbind() accepts a string describing the event type to unbind.
- .undelegate() removes the binding
- .unload()
- use bind/trigger to create custom event