Hi Hector,
John Resig wrote a plugin method a while back called .nextUntil() ,
which I thought was going to make it into version 1.2, but apparently
it didn't. I see nextAll(), but that doesn't quite do what you want
either.
I don't have time to test this to make sure it works with 1.2, but
here is John's code:
$.fn.nextUntil = function(expr) {
var match = [];
if ( expr.jquery )
expr = expr[0];
// 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;
// If we find a match then we need to stop
if ( expr.nodeType ) {
if ( i == expr ) break;
} else if ( jQuery.multiFilter( expr, [i] ).length ) break;
// Otherwise, add it on to the stack
match.push( i );
}
});
return this.pushStack( match, arguments );
};
Usage would be:
$("tr.versionSection").click(function() {
$(this).nextUntil("tr.versionSection").toggle();
});
And here is John's test page:
http://dev.jquery.com/~john/jquery/test/nextuntil.html
Hope that helps,
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Sep 18, 2007, at 3:21 PM, Pops wrote:
I have a table with some <tr> is used as divide other rows:
<tr class="versionSection">....
<tr>...
<tr>..
<tr>..
<tr class="versionSection">....
<tr>..
<tr>..
...
<tr class="versionSection">....
<tr>..
<tr>..
etc.
In lieu of changng the HTML page, I want to see if I can find the <tr>
after each class="versionSection" row. I want to do a toggler for
each section.
//----------------------------------------------------------
// - Click title row to toggle the remaing section rows.
//----------------------------------------------------------
var $f = $(".versionSection");
$f.click(function() {
var $r = $(this).next("tr > !.versionSection");
$r.toggle();
});
//----------------------------------------------------------
Its close, but obviously not right. It only gets the first next row.
I need it to return all the rows until the next .versionSection class
row..
Any tips in a selector?
TIA
--
HLS