this is working pretty good but i noticed one problem. It only surrounds the first html attribute.
My content would be more like this... <h2>some dummy text</h2> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam malesuada suscipit pede. Nullam ipsum lacus, varius vel, nonummy in, consequat ut, neque. </p> <h3>Lorem ipsum</h3> <p>Nullam malesuada suscipit pede. Nullam ipsum lacus, varius vel, nonummy in, consequat ut, neque. Vivamus viverra. Duis dolor arcu, lacinia sit amet, sollicitudin sed, aliquet vel, quam. Pellentesque molestie laoreet tortor. Aenean quam. Pellentesque magna metus, venenatis sit amet, congue nec, dictum in, est. Aliquam nibh. </p> <h2>some more dummy text</h2> <p>Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. </p> <p>Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque</p> <h2>anything else</h2> <p>Here could be your content</p> Any way to surround all html elements down to the next H2? On Feb 19, 12:21 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > actually i should clarify... not "change", but wrap the elements following > h2 elements with the specified HTML. > > On Thu, Feb 19, 2009 at 10:00 AM, Charlie Griefer <charlie.grie...@gmail.com > > > > > > > wrote: > > On Thu, Feb 19, 2009 at 9:27 AM, cchun...@gmail.com > > <cchun...@gmail.com>wrote: > > >> I am trying to look through content in a div and if i find an H2 or > >> whatever attribute the content or HTML that follows it will be > >> encloded in a div with a class. I will do this for every H2 so if i > >> have 3 H2's and some paragraphs after them it will surround all HTML > >> after each of the H2 in a div. > > > This will change the element following all h2 elements in the doc. > > > <script> > > $(function() { > > $('h2').next().wrap('<div class="someclass"></div>'); > > }); > > </script> > > > If you want it to be just within a certain div, and assuming that div has > > an id attribute of "foo", it would be: > > > <script> > > $(function() { > > $('#foo h2').next().wrap('<div class="someclass"></div>'); > > }); > > </script> > > > -- > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > > -- > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success.- Hide quoted text - > > - Show quoted text -