Revision: 4844
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 23, 2008 14:06 by thecrumb
Initial Code
/******** next until > ****************/
$.fn.nextUntil = function(expr) {
var match = [];
// 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 ( jQuery.filter( expr, [i] ).r.length ) break;
// Otherwise, add it on to the stack
match.push( i );
}
});
return this.pushStack( match, arguments );
};
/******** < next until ****************/
Initial URL
Initial Description
Then, your code should look like this ...
$(document).ready(function() {
$("dt > a").click(function(){
$(this).parent().nextUntil('dt').toggle();
return false;
});
});
Initial Title
jquery - nextUntil
Initial Tags
jquery
Initial Language
JavaScript