Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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")

Up to jQuery version 4, the event order was as follows:

  • focusout

  • blur

  • focusin

  • focus

Starting with jQuery 4.0, the event order will match the current W3C specification:

  • blur

  • focusout

  • focus

  • focusin

The only browser that has a different order is IE, but the irony is that IE was once the only browser that followed the previous W3C specification, while all other browsers used their own event order, which only became the standard in 2023 ¯\(ツ)/¯

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

No need to memorize all events — you can always find them on the MDN pages from Mozilla.

Last updated