Suggestion: .nextWrap() and .prevWrap()

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:

  1. (function($){
  2.     $.fn.nextWrap = function() {
  3.         var $next = this.next();
  4.         return ($next.length === 0) ? this.siblings().first() : $next;
  5.     };
  6.    
  7.     $.fn.prevWrap = function() {
  8.         var $prev = this.prev();
  9.         return ($prev.length === 0) ? this.siblings().last() : $prev;
  10.     };
  11. })(jQuery);