Suggestion: .nextWrap() and .prevWrap()
I don't speak english natively, but I'll try to explain it as clearly as I can:
The functions would work like .next() and .prev(), but with a wrap when it reaches the last (or first) sibling:
- (function($){
- $.fn.nextWrap = function() {
- var $next = this.next();
- return ($next.length === 0) ? this.siblings().first() : $next;
- };
-
- $.fn.prevWrap = function() {
- var $prev = this.prev();
- return ($prev.length === 0) ? this.siblings().last() : $prev;
- };
- })(jQuery);