FocusEvent: FocusEvent() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The FocusEvent() constructor returns a newly created FocusEvent object with an optional EventTarget. When the event has both a source and a destination, the relatedTarget value must be set to the other target.

Syntax

js
new FocusEvent(type)
new FocusEvent(type, options)

Parameters

The FocusEvent() constructor also inherits arguments from UIEvent() and from Event().

type

A string with the name of the event. It is case-sensitive and browsers set it to blur, focus, focusin, or focusout.

options Optional

An object that, in addition of the properties defined in UIEvent(), can have the following properties:

relatedTarget Optional

An EventTarget representing the secondary target of a FocusEvent. It defaults to null.

Specifications

Specification
UI Events
# dom-focusevent-focusevent

Browser compatibility

BCD tables only load in the browser

See also