検索結果の項目を上下矢印キーで選択したいのですが、
次のリンクはフォーカスされませんが、何が間違っていますか?
http://jsfiddle.net/JJDfL/1/でライブ
$('#hitbox').on('keyup','a', function(event) {
//focus prev/next with arrows, enter and escape
if (event.keyCode == 27) {
$('#hitbox').slideUp(100);
$('#searchbox').val('');
$('#searchbox').focus();
}
if(event.keyCode == 40) {
var focused = $(':focus');
focused.parent().next().focus();
alert(focused.parent().next().html()); //returns '<a href="asdf">bb</a>'
}
});
アップデート:
今動作します:
focused.parent().next().find('a').focus();
問題を解決しました。