On 14/11/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> Sam Collett schrieb:
> > Say I have a list:
> >
> > <ul id="mylist">
> > <li>Item 1</li>
> > <li>Item 2</li>
> > <li>Item 3</li>
> > <li>Item 4</li>
> > <li>Item 5</li>
> > </ul>
> >
> > I attach a click event to each (actually I would append an anchor and
> > attach to that, but for simplicities sake). How would I then get all
> > nodes prior to it (i.e. if I click Item 3, Item 1 + 2 move after Item
> > 5)?
> >
> > $("#mylist li").click(
> > function()
> > {
> > var current = $(this);
> > var previous = current.???;
> > previous.appendTo("#mylist");
> > }
> > )
> >
> > What would be ideal is if prev and next had an overload to get all
> > previous/next, not just the immediate one. Or click had two parameters
> > click(event, index)
> >
> > I'm thinking jQuery Tabs, but with the selected tab always as the
> > first one (with an animation fading out (or sliding left) the previous
> > tabs and fading them in at the end of the list).
>
>
> Hi Sam,
>
> you could try to use index() for this:
>
> $('#mylist li').click(function() {
> var all = $('li', this.parentNode);
> var currentIndex = all.index(this);
> var previousSiblings = all.lt(currentIndex);
> });
>
> Not tested though...
>
>
> -- Klaus
A demo of what I am doing:
http://www.texotela.co.uk/tabtest.php
I would rather slideLeft to hide and then slideRight to show, but
those fx don't exist (the syntax for these would be something like
slideLeft(speed,showorhide,callback)). Also the fadeIn fires for each
item prior to the one that was clicked. I want to apply the effect to
them as a group, not individually.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/