I have a direct search that shows the results and allows you to use the up and down arrows when the results pop up, but I want the cursor to not move left or right when using the up and down arrows. I can’t figure it out. I tried e.preventDefault()with no luck. Here is what I tried:
if(e.which == 40){
e.preventDefault();
current = results.find('li.hover');
current.removeClass();
var next = current.next('li');
if(next.length == 0){
next = current.parent().parent().parent().next().find('li:first');
/* Go back to the top */
if(next.length == 0){
next = results.find('li:first');
}
}
next.addClass('hover');
return false;
}
Thank!
source
share