The following is largely based on these test results
According to DOM Level 3 Focus Event Order there is a whole slew of events to be dispatched upon change of focus. focusin
and focus
are the two events dispatched the first time any element of the document receives focus. After that, when focus shifts to another element, we first get focusout
on the element that has focus, then focusin
on the element that will receive focus, then blur
on the element that just lost focus, then focus
on the element that got focus.
[…]
While focusout
and focusin
sound like the superior choice, they are not supported in Gecko at all. Blink 449857, WebKit 140596, [Trident 1