this
Most JavaScript-applications perform actions as a response to events.
An event is a signal from the browser that something has happened.
which/button
mouseover/mouseout
relatedTarget
Mousemove
mouseover
Mouseout
clientX(Y)
pageX(Y)
oncontextmenu
This section covers properties and specials of mouse-related events.
focus
onblur
The focus event triggers when a visitor focuses on an element.
Not all elements are focusable by default. For example, INPUT and all types or form fields support this event, A supports it. As a counterexample, DIV doesn’t support focus.
INPUT
A
DIV
The event delegation helps to simplify event handling by smart use of bubbling. It is one of the most important JavaScript patterns.
keypress
keydown/keyup
Keyboard events is one of wilder parts of frontend development. There are inconsistencies and cross-browser problems.
But still there are recipes which help to cope with ordinary situations easily.
The event object is always passed to the handler and contains a lot of useful information what has happened.
event.target
DOM elements can be nested inside each other. And somehow, the handler of the parent works even if you click on it’s child.
The reason is event bubbling.
A browser has its own “default” behavior for certain events.
For instance: