focus

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.

O evento focus é acionado assim que um elemento recebe um foco. O grande diferencial entre este evento e o evento focusin, é que esse segundo "borbulha".

Informações Gerais

Especificação

DOM L3

Interface
FocusEvent
Borbulha

Não

Cancelável

Não

Alvo

Element

Ação Padrão

Nenhuma.

Nota: Note: The interface was Event prior to Gecko 24. (Firefox bug 855741)

Propriedades

Property Type Description
target Somente leitura EventTarget Event target (DOM element)
type Somente leitura DOMString The type of event.
bubbles Somente leitura Boolean Whether the event normally bubbles or not.
cancelable Somente leitura Boolean Whether the event is cancellable or not.
relatedTarget Somente leitura EventTarget (DOM element) null

Eventos Delegados

Existem 2 maneiras diferentes de implementações delegados a partir de um evento: por meio da utilização do evento focusin que todos os browsers atuais suportam tão tecnologia (todos exceto o Firefox), ou por setando o parâmetro "useCapture" do elemento addEventListener como true:

{{ EmbedLiveSample('Event_delegation', '', '', '', 'Web/Events/blur') }}

(Exemplo de codigo do evento blur (event))

Especificações

Specification
UI Events
# event-type-focus
HTML
# handler-onfocus

Compatibilidade com navegadores

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
focus event

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

Eventos Relacionais