jquery - nextUntil


/ Published in: JavaScript
Save to your folder(s)

Then, your code should look like this ...

$(document).ready(function() {
$("dt > a").click(function(){
$(this).parent().nextUntil('dt').toggle();
return false;
});
});


Copy this code and paste it in your HTML
  1. /******** next until > ****************/
  2. $.fn.nextUntil = function(expr) {
  3. var match = [];
  4.  
  5. // We need to figure out which elements to push onto the array
  6. this.each(function(){
  7. // Traverse through the sibling nodes
  8. for( var i = this.nextSibling; i; i = i.nextSibling ) {
  9. // Make sure that we're only dealing with elements
  10. if ( i.nodeType != 1 ) continue;
  11.  
  12. // If we find a match then we need to stop
  13. if ( jQuery.filter( expr, [i] ).r.length ) break;
  14.  
  15. // Otherwise, add it on to the stack
  16. match.push( i );
  17. }
  18. });
  19.  
  20. return this.pushStack( match, arguments );
  21. };
  22.  
  23. /******** < next until ****************/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.