Monday, April 27, 2009

[jQuery] Re: jQuery next() to find <select><option>

thanks for the quick answer, unfortunately no, I can't understand why
but it returns "undefined"

On Apr 27, 5:37 pm, Remon Oldenbeuving <r.s.oldenbeuv...@gmail.com>
wrote:
> hi,
>
>        $(document).keydown (function(e) {
>                if (e.keyCode == 37)
>                        if(n == $('select
> option:selected').prev('option').val())
>                                location.href = n;
>                if (e.keyCode == 39)
>                        if(n == $('select
> option:selected').next('option').val())
>                                location.href = n;
>        });
>
> If i get you right, this should do the trick?
>
> On Mon, Apr 27, 2009 at 10:30 PM, dimitre <dimitr...@gmail.com> wrote:
>
> > Hello I am using jQuery next() and prev() to navigate inside
> > <select><option> tags.
> > problem is I am using <optgroup> too and can't find a way to make it
> > work
>
> > ex:
> > <select>
> >                        <optgroup label="Motion">
> >                        <option value="/m01/" >001</option>
> >                        <option value="/m02/" >002</option>
> >                        <option value="/m03/" selected>003</option>
> >                        <optgroup label="illustration">
> >                        <option value="/illustration01/"
> > >illustration01</option>
> >                        <option value="/illustration02/"
> > >illustration02</option>
> > </select>
>
> >        $(document).keydown (function(e) {
> >                if (e.keyCode == 37)
> >                        if(n = $('select option:selected').prev().val())
> >                                location.href = n;
> >                if (e.keyCode == 39)
> >                        if(n = $('select option:selected').next().val())
> >                                location.href = n;
> >        });

No comments: