Hi everyone! I wanted to use nextUntil, but noticed that it was broken in jQuery 1.3.2 (I know that the "plugin" isn't official yet and that is wanted in the core - looking at the roadmap).
Well, this line wasn't working: // If we find a match then we need to stop if ( jQuery.filter( expr, [i] ).r.length ) break; I'm curious, what was the r-property doing there before? :) Well, I created a small patch, that also gives the oppurtunity to also include the last selector default is as usual: $("h3").nextUntil(); => [ div, p, p, h3, div, p ] $("h3").nextUntil("h3"); => [ div, p, p ] But if a last value true is given, it also includes that that last selector: $("h3").nextUntil("h3", true); => [ div, p, p, h3 ] Hope that someone can make use of this. All credit goes to John Resig for his excellent work with jQuery ( jQuery.fn.nextUntil = function(expr, include) { var match = []; include = include ? true : false // We need to figure out which elements to push onto the array this.each(function(){ // Traverse through the sibling nodes for( var i = this.nextSibling; i; i = i.nextSibling ) { // Make sure that we're only dealing with elements if ( i.nodeType != 1 ) continue; // Add it on to the stack if include is set if ( include ) { match.push( i ); } // If we find a match then we need to stop if ( jQuery.filter( expr, [i] ).length ) break; // Add it on to the stack if include is not set if (! include ) { match.push( i ); } } }); return this.pushStack( match, arguments ); } Best regards Johan Borestad