Encapsulate a set of divs with another div in jQuery
- by lafoaug
Hi,
I am a little stumped with how to do this.
I am using jQuery and wish to encapsulate certain sets of divs with a div.
For example I have:
<div class="group-1">x</div>
<div class="group-1">x</div>
<div class="group-2">x</div>
<div class="group-2">x</div>
<div class="group-3">x</div>
And wish to end up with:
<div id="set-1">
<div class="group-1">x</div>
<div class="group-1">x</div>
</div>
<div id="set-2">
<div class="group-2">x</div>
<div class="group-2">x</div>
</div>
<div id="set-3">
<div class="group-3">x</div>
</div>
I am able to cycle through each div and add a div around each one but not the way I want above. Any advice appreciate.
Thanks.