あなたが抱えている問題は、フォーカスのあるアイテムを取得しようとするが、それを早くすることです。だからあなたがすることはこれです:
blur event gets fired
you try to get the element which has got focus
new element gets focus
確かに最も簡単な方法は、フォーカスのためにイベントリスナーを追加することですが、それをしたくない場合は、これがトリックになります:
$("input").blur(function() {
setTimeout(function() {
console.log($(":focus"));
}, 1);
});
ライブデモ
アップデート
タイムアウトを設定すると、常にパフォーマンスに依存するため、実際には最良の解決策は次のとおりです。
var sTempId;
$("input")
.focus(function() {
if (sTempId)
console.log ( sTempId + " -> " + $(this).attr("id") );
sTempId = $(this).attr("id");
});
ライブデモ