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.

Reply via email to