I have made an search function where you can navigate the results with your keyboard arrows. All results will show up in li
's inside a div
with style:
overflow:auto; max-height: 100px;
I focus the first li
with this code:
$('#searchInput').keydown(function(e) {
if (e.keyCode==40) {
$('li:first').focus();
}
});
The div
with overflow:auto
will then auto scroll so the first focused li
won't be visible...
Here is an example: http://jsfiddle.net/CZz9n/1/