hi guys ... my html is something like that
<h3>head1</h3> <p>content content</p> <h3>head2</h3> content content content Now i want to add divs to split this into containers. It should look like that <div class="1"> <h3>head1</h3> <p>content content</p> </div> <div class="2"> <h3>head2</h3> content content content </div> What is the best way to do this?? I started with somethink like that: var first = jQuery('div.prod_left_content h3:first').html(); jQuery('div.prod_left_content h3').each(function(){ var catname = jQuery(this).html(); if (catname==first) { jQuery(this).before('<div class="t'+z+'">'); } else { jQuery(this).before('</div><div class="t'+z+'">'); } z++; }); // last clos div tag var lastel = jQuery('div.prod_left_content *:last'); jQuery(lastel).after('</div>'); The problem with that is that before ignores the div close tag. Thanks for help