FocusEvent

The FocusEvent interface represents focus-related events, including focus, blur, focusin, and focusout.

Event UIEvent FocusEvent

Constructor

FocusEvent()

Creates a FocusEvent event with the given parameters.

Instance properties

This interface also inherits properties from its parent UIEvent, and indirectly from Event.

FocusEvent.relatedTarget

An EventTarget representing a secondary target for this event. In some cases (such as when tabbing in or out a page), this property may be set to null for security reasons.

Instance methods

This interface has no specific methods. It inherits methods from its parent UIEvent, and indirectly from Event.

Order of events

The UI Events specification states that focus events occur in a set order relative to one another, and goes on to describe the typical sequence of events that fire when the focus is shifted from element A to element B:

  1. focusout: sent before element A loses focus.
  2. focusin: sent before element B receives focus.
  3. blur: sent after element A loses focus.
  4. focus: sent after element B receives focus.

However, current browser implementations fire these four events in a different order:

  1. blur: sent after element A loses focus.
  2. focusout: sent after the blur event.
  3. focus: sent after element B receives focus.
  4. focusin: sent after the focus event.

Specifications

Specification
UI Events
# interface-focusevent

Browser compatibility

BCD tables only load in the browser

See also

  • The Event base interface