[jQuery] Get all previous/next siblings
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).
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/