[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-13 Thread ricardobeat
Ah, thanks Karl, writing to this list has become one of my favorite spare time hobbies :) On Nov 13, 1:23 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote: > Not a problem, Ricardo. :-) > > sorry, everyone else, for going off-topic, but I'd like to thank   > Ricardo publicly for all the help he has be

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-13 Thread Karl Swedberg
Not a problem, Ricardo. :-) sorry, everyone else, for going off-topic, but I'd like to thank Ricardo publicly for all the help he has been giving to this list in the past few months. Ricardo, your contributions are much appreciated. Cheers, --Karl Karl Swedberg www.englishrul

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-13 Thread ricardobeat
Oops. I always do that, write a non-functional draft in the reply body and forget to correct it after testing! Thanks :D On Nov 13, 2:21 am, Karl Swedberg <[EMAIL PROTECTED]> wrote: > Actually, Ricardo's should work if ... > > 1. you change var $this = this; to var $this = $(this); > 2. you know

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread Karl Swedberg
On Nov 12, 2008, at 11:17 PM, Karl Swedberg wrote: Hi Adam, In that case, you'll probably need to use John Resig's nextUntil plugin. The way I managed to do it is a little sneaky. Someone else should be able to come up with a better way. But in the meantime, you can take a look at a wor

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread Adam
Beautiful! That edit worked with Ricardo's script. Thank you both very much! -Adam On Nov 12, 9:21 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote: > Actually, Ricardo's should work if ... > > 1. you change var $this = this; to var $this = $(this); > 2. you know for sure you'll only have two paragrap

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread Karl Swedberg
Actually, Ricardo's should work if ... 1. you change var $this = this; to var $this = $(this); 2. you know for sure you'll only have two paragraphs after each h1 --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Nov 12, 2008, at 9:04 PM, Adam wrote: Ricardo

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread Karl Swedberg
Hi Adam, In that case, you'll probably need to use John Resig's nextUntil plugin. The way I managed to do it is a little sneaky. Someone else should be able to come up with a better way. But in the meantime, you can take a look at a working example here Just view source for the script. --

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread Adam
Ricardo, Thanks for your response. Are you sure about this syntax? Ive tried this and there's no result. The code is not modified at all... -Adam On Nov 12, 4:09 pm, ricardobeat <[EMAIL PROTECTED]> wrote: > This should work for this specific case (separated in lines for > readability): > > $('h1

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread ricardobeat
This should work for this specific case (separated in lines for readability): $('h1').each(function(){ var $this = this; $this .add( $this.next() ) .add( $this.next().next() ) .wrapAll(''); }); - ricardo On Nov 12, 7:48 pm, Adam <[EMAIL PROTECTED]> wrote: > Karl, >

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread Adam
Karl, Thanks very much. My bad, but what I actually need is the div wrapped around each of the sets of h1,p,p. So, the resulting code must be: ... ... ... ... ... ... I have tried a number of different things, and this function works to wrap the first set of 3 in the div: $("#content h1:nt

[jQuery] Re: selector to .wrap multiple elements in HTML

2008-11-12 Thread Karl Swedberg
Hi Adam, Take a look at the .wrapAll() method. that should get you closer. You'll need to select all of the elements first, though. $('h1 + p + p') only selects that final p. If you want to wrap the div around all h1 and p elements, you could try $('h1,p').wrapAll('class="fade">'); --Kar