| For anyone using John's excellent nextUntil plugin in conjunction with wrapAll, I made a slight change that might be of use to some folks. I have several long pages of content that I'm breaking into subpages and building a dynamic in-page navigation system for clicking through them without reloading. In my case, I want a new subpage to start with every H3 tag. so my script is: $('.page').nextUntil('H3').wrapAll('<div class="subpage"></div>'); But I noticed that the H3s weren't getting wrapped. So it looks like nextUntil is building a collection of everything AFTER the H3, but not including the H3 itself. So I made a slight tweak, as shown in bold below, and that solved my problem. $.fn.nextUntil = function(expr) { var match = []; // We need to figure out which elements to push onto the array this.each(function(){ match.push(this); // 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; // If we find a match then we need to stop if ( jQuery.filter( expr, [i] ).r.length ) break; // Otherwise, add it on to the stack match.push( i ); } }); return this.pushStack( match, arguments ); }; I suppose it could be argued that it's not really a nextUntil plugin anymore, but this is what I needed it to do. Thanks again, John. -p |
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
