42

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

FishBasketGordo
  • 22,904
  • 4
  • 58
  • 91
Randomblue
  • 112,777
  • 145
  • 353
  • 547
  • 2
    http://stackoverflow.com/questions/7858979/difference-between-focusin-focusout-and-focus-blur-with-example – zloctb Feb 01 '17 at 14:41

4 Answers4

50

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.

João Pimentel Ferreira
  • 14,289
  • 10
  • 80
  • 109
shabunc
  • 23,119
  • 19
  • 77
  • 102
7

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/

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
4

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).

FishBasketGordo
  • 22,904
  • 4
  • 58
  • 91
1

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.

NimaDoustdar
  • 318
  • 3
  • 5