I create fiddle:
http://jsfiddle.net/marko4286/7TmJc/
function arrowUp() {
var activeTableRow = $('.table tbody tr.active').removeClass('active').first();
if (activeTableRow.length) {
activeTableRow.prev().addClass('active');
} else {
$('.table tbody').children().last().addClass('active');
}
};
function arrowDown() {
var activeTableRow = $('.table tbody tr.active').removeClass('active').first();
if (activeTableRow.length) {
activeTableRow.next().addClass('active');
} else {
$('.table tbody').children().first().addClass('active');
}
};
$(window).keydown(function (key) {
if (key.keyCode == 38) {
arrowUp();
}
if (key.keyCode == 40) {
arrowDown();
}
});
The problem is when I use the up/down arrow keys, and when I have a vertical scroll. When it comes to an end automatically returns to the first row.
I would like to stop selecting up when I'm on the first row and selecting rows down when I'm on the last row.
Also, the problem is that I have a vertical scrolling, selecting rows via the arrow is farewell as it should, because it automatically scrolls the div (example of how it should work selecting a row when table or div has vertical scroll http://dhtmlx.com/docs/products/dhtmlxGrid /)