[jQuery] Re: selecting next()'s until I reach a tag
Try: $('h5').nextAll('p'); Maurício -Mensagem Original- De: Andy Para: jQuery (English) Enviada em: quarta-feira, 27 de maio de 2009 14:11 Assunto: [jQuery] selecting next()'s until I reach a tag Is there a way for me to add the next several blocks until I get to a specific tag?
[jQuery] Re: selecting next()'s until I reach a tag
Thanks for the suggestion! That sort of works, but it's also getting the p tags AFTER the next H5, and I don't want it to. On May 27, 1:24 pm, Mauricio \(Maujor\) Samy Silva css.mau...@gmail.com wrote: Try: $('h5').nextAll('p'); Maurício -Mensagem Original- De: Andy Para: jQuery (English) Enviada em: quarta-feira, 27 de maio de 2009 14:11 Assunto: [jQuery] selecting next()'s until I reach a tag Is there a way for me to add the next several blocks until I get to a specific tag?
[jQuery] Re: selecting next()'s until I reach a tag
Please have a look at: http://docs.jquery.com/JQuery_1.2_Roadmap#.nextUntil.28.29_.2F_.prevUntil.28.29 Maurício -Mensagem Original- De: Andy Para: jQuery (English) Enviada em: quarta-feira, 27 de maio de 2009 14:32 Assunto: [jQuery] Re: selecting next()'s until I reach a tag Thanks for the suggestion! That sort of works, but it's also getting the p tags AFTER the next H5, and I don't want it to. On May 27, 1:24 pm, Mauricio \(Maujor\) Samy Silva css.mau...@gmail.com wrote: Try: $('h5').nextAll('p'); Maurício
[jQuery] Re: selecting next()'s until I reach a tag
That looks great but I don't know how to implement it into my jQuery library. When I include it in the page or in my jQuery file, I get all sorts of errors. On May 27, 2:58 pm, Mauricio \(Maujor\) Samy Silva css.mau...@gmail.com wrote: Please have a look at:http://docs.jquery.com/JQuery_1.2_Roadmap#.nextUntil.28.29_.2F_.prevU... Maurício -Mensagem Original- De: Andy Para: jQuery (English) Enviada em: quarta-feira, 27 de maio de 2009 14:32 Assunto: [jQuery] Re: selecting next()'s until I reach a tag Thanks for the suggestion! That sort of works, but it's also getting the p tags AFTER the next H5, and I don't want it to. On May 27, 1:24 pm, Mauricio \(Maujor\) Samy Silva css.mau...@gmail.com wrote: Try: $('h5').nextAll('p'); Maurício
[jQuery] Re: selecting next()'s until I reach a tag
Do a loop like this (this example adds alternating colors to the groups of paragraphs): $('h5').each(function(i){ var colors = ['green', 'red', 'blue']; n = $(this), ps = []; while( (n = n.next()).length !n.is('h5') ) ps.push( n[0] ); $(ps).css('color', colors[i%3]); }); Or use this (by John Resig, I think I've posted this a dozen times already..): jQuery.fn.nextUntil = function(expr) { var match = []; this.each(function(){ for( var i = this.nextSibling; i; i = i.nextSibling ) { if ( i.nodeType != 1 ) continue; if ( jQuery.filter( expr, [i] ).length ) break; match.push( i ); } }); return this.pushStack( match, arguments ); }; $('h5').each(function(){ $(this).nextUntil('h5').bleh(); }); On May 27, 2:32 pm, Andy andym...@gmail.com wrote: Thanks for the suggestion! That sort of works, but it's also getting the p tags AFTER the next H5, and I don't want it to. On May 27, 1:24 pm, Mauricio \(Maujor\) Samy Silva css.mau...@gmail.com wrote: Try: $('h5').nextAll('p'); Maurício -Mensagem Original- De: Andy Para: jQuery (English) Enviada em: quarta-feira, 27 de maio de 2009 14:11 Assunto: [jQuery] selecting next()'s until I reach a tag Is there a way for me to add the next several blocks until I get to a specific tag?