Briefly,
.focusin()
and .focusout()
are events that "bubble", while .focus()
and .blur()
do not.
Executing the example below you will notice that input
calls all events, parent
only focusin
and focusout
.
obs * "Bubbling" is the concept that defines the propagation of an event to different levels of the DOM hierarchy.
function log(str){
$('.log').append($('<div/>').text(str));
}
$('.parent')
.focusin(function(){log('div focusin');})
.focusout(function(){log('div focusout');})
.focus(function(){log('div focus');})
.blur(function(){log('div blur');});
$('input')
.focusin(function(){log('input focusin');})
.focusout(function(){log('input focusout');})
.focus(function(){log('input focus');})
.blur(function(){log('input blur');});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="parent">
<input type="text" />
</div>
<div class="log"></div>
Snippet source: diff between focus focusin