I\'ve got a little issue with the focus event that I just became aware of. Apparently, focus fires when switching to another browser tab and then back again. I\'d rather not hav
Try this
var times = 0;
var prevActiveElement;
$( window ).on( "blur", function(e){
prevActiveElement = document.activeElement;
});
$('input').on('focus', function() {
if (document.activeElement === prevActiveElement) {
return;
}
prevActiveElement = document.activeElement;
times++;
$(this).after('
Focused ' + times + ' times');
}).on( "blur", function(){
prevActiveElement = null;
});