30% Events
Before diving into this chapter, let's figure out what web page events actually are. So, events are user actions — typing on the keyboard, scrolling the page, moving the mouse, and of course, "clicking".
There are also events created by scripts, along with their handlers — triggers and handlers, but more on that a bit later.
jQuery works with practically all JavaScript events. Here's a list of the most commonly used ones with brief explanations:
click
click on an element;
event order: mousedown → mouseup → click
dblclick
double mouse click
mousedown
mouse button pressed
mouseup
mouse button released
mousemove
cursor movement
mouseenter
cursor enters an element; does not fire when focus moves to child elements
mouseleave
cursor leaves an element; does not fire when focus moves to child elements
mouseover
cursor enters an element
mouseout
cursor leaves an element
Moving on. Here's another dozen events, mostly related to form elements:
focus
element receives focus;
relevant for input[type=text], but in modern browsers works with other elements too
blur
element loses focus; fires when clicking on another element on the page or via a keyboard event (e.g., tabbing)
focusin
element receives focus;
this event is similar to focus, but it also "bubbles"
focusout
element loses focus;
this event is similar to blur, and it "bubbles" (you can read more about the differences in the article "Focusing: focus/blur")
change
element value changed (the value on blur differs from the initial value on focus)
keydown
keyboard key pressed
keypress
keyboard key held down, sequence: keydown → keypress → keyup (only for letters and numbers)
keyup
keyboard key released
select
text selection for input[type=text] and textarea
submit
form submission
Also worth mentioning are a couple more popular events you'll work with:
resize
document size changed
scroll
element or window scrolled
Last updated