[jQuery] Fetching objects siblings with the siblings() method

[jQuery] Fetching objects siblings with the siblings() method

Hi,
I have been playing around with the siblings method in the jQuery alpha,
I modified it so that it no longer returns the element itself and also
so that the order of the returned elements shows the next sibling as the
first element in the list and the previous element as the last. This
makes looping through siblings (for instance in a slide show) a lot
easier, for instance in a list like this:
[ 1, 2 , 3 ,4 ]
The siblings of 2 would be
[ 3 , 4 , 1 ]
This is the relevant function:
siblings: function(a) {
var ret = jQuery.map(this.cur,jQuery.sibling);
if ( a ) ret = jQuery.filter(a,ret).r;
for(var i=0; i<ret.length; i++) {
obj = ret.shift();
if(obj == this.get(0)) break;
ret.push(obj);
}
return this.pushStack(ret);
},
I am quite new to Javascript, so I would appreciate any feedback on how
to shorten or improve on my change.
Cheers,
Lachlan Donald
--
SitePoint.com <http://www.sitepoint.com/>
Lachlan Donald
Web Developer
SitePoint Pty. Ltd.
e: lachlan@sitepoint.com
w: http://www.sitepoint.com/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/