Hello... this has to be something poeple have done before. I managed
to only do about half of what I intended to - I'm stuck in the middle
(seee //comment).

I got a list of stuff and want to be able to select items using the
arrow keys.

<ol>
<li class="item">blah</li>
...etc...

I've bound key events to the OL but am stuck getting a clean and
simple solution for doing the following:
1. check if any Li has class 'active'
2. if no such luck, set the first Li 's class to active.
3. if I do find a Li with 'active' class, return its index

So, I tried this:

$('ol').bind('keydown, keyup', function(event) {
  if(event.keyCode==38 || event.keyCode==40){
    $('ol > li').each(function(element){
      if( $(this).hasClass('active') ){
        // and now I'm stuck and don't know what to do. is this even
the right approach?
     }
    }
  }
}

Reply via email to