Randomblue
Randomblue

Reputation: 116293

Difference between the javascript/jQuery events "focus" and "focusin"?

What is the difference between these two events: focus and focusin?

Upvotes: 50

Views: 28628

Answers (4)

NimaDoustdar
NimaDoustdar

Reputation: 326

The focusin events bubble, the focus events doesn't. That means that you can use the focusin on the parent element of a form field.

Upvotes: 1

shabunc
shabunc

Reputation: 24741

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event, in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

This event will likely be used together with the focusout event.

Upvotes: 56

FishBasketGordo
FishBasketGordo

Reputation: 23142

According to the jQuery focusin documentation:

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

Upvotes: 4

Jared Farrish
Jared Farrish

Reputation: 49208

The focusin event is sent to an element when it, or any element inside of it, gains focus. This is distinct from the focus event in that it supports detecting the focus event on parent elements (in other words, it supports event bubbling).

http://api.jquery.com/focusin/

Upvotes: 7

Related Questions