lewis,
First, use pastebin.com or something like next time, it'll help us
help you.

So, you need to wrap each group of h2 + div + p + p.postmetadata

Check out http://snipplr.com/view/4746/jquery--nextuntil/

and you should be able to do something like:

$('h2').nextUntil('.scrollablePost').wrap('<div>')

If that does not work, maybe

$('h2')
.each(function(){
$(this).nextUntil('.scrollablePost').wrap('<div>')
});

If that still does now work, can you post your code to pastebin so I
have something work with?

On Aug 20, 10:55 am, ldexterldesign <m...@ldexterldesign.co.uk> wrote:
> Don't you think I thought about using that straight away?
>
> How can I wrap a group of elements in the DOM when I don't know what
> elements will be there in first place. I'm aiming to wrap,
> essentially, a blog post, so:
>
> $(document).ready(function(){
>         $('h2').wrap('<div class="scrollablePost"></div>');
>         }); // would be fine
>
> ...but try doing this:
>
> $(document).ready(function(){
>         $('<h2><bunchOfOtherElements?>...</bunchOfOtherElements?><div
> class="postmetadata"></div>').wrap('<div class="scrollablePost"></
> div>');
>         });
>
> :|
>
> Thanks,
> L
>
> On Aug 20, 3:36 pm, ak732 <ask...@gmail.com> wrote:
>
>
>
> > go to:http://api.jquery.com/andput "wrap" in the filter box
>
> > On Aug 20, 10:06 am, ldexterldesign <m...@ldexterldesign.co.uk> wrote:
>
> > > Yo guys,
>
> > > I need to wrap this chuck of HTML in a <div>:http://is.gd/2qatX
>
> > > Any thoughts?
>
> > > $(document).ready(function(){
> > >         $('<div class="scrollablePost">').insertBefore('.page-id-9 h2');
> > >         $('</div>').insertAfter('.page-id-9 .postmetadata');
> > >         });
>
> > > ...just pumps out <div class="scrollablePost" /> at both ends, as
> > > you'll see from the above screenshot.
>
> > > Thanks,
> > > L

Reply via email to