Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between focusin/focusout vs focus/blur in jQuery? [duplicate]

I was handling some events using the following code with jQuery 1.7.2:

$().on('focus blur', function(event) {
  console.log(event.type);
});

And I have noticed that event.type for both events, prints out: focusin and focusout.

What is difference between focusin/focusout vs focus/blur?

like image 848
Rubens Mariuzzo Avatar asked May 14 '12 13:05

Rubens Mariuzzo


1 Answers

Short answer: focusin    bubbles, focus does not.
        focusout bubbles, blur   does not.
Read the docs:

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

like image 118
gdoron is supporting Monica Avatar answered Oct 24 '22 01:10

gdoron is supporting Monica