Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 20th, 2012  |  syntax: JavaScript  |  size: 0.90 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function moveSelection(direction) {
  2.                     if ($(":visible", results_holder).length > 0) {
  3.                         var lis = $("li", results_holder);
  4.                         if (direction == "down") {
  5.                             var start = lis.eq(0);
  6.                         } else {
  7.                             var start = lis.filter(":last");
  8.                         }
  9.                         var active = $("li.active:first", results_holder);
  10.                         if (active.length > 0) {
  11.                             if (direction == "down") {
  12.                                 start = active.next();
  13.                             } else {
  14.                                 start = active.prev();
  15.                             }
  16.                         }
  17.                         lis.removeClass("active");
  18.                         start.addClass("active");
  19.                     }
  20.                 }