Hello, I have a set of selected elements in jQuery:
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
I would like to wrap these elements into groups of five like so:
<div class="wrapper">
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
</div>
<div class="wrapper">
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
</div>
<div class="wrapper">
<div class="element"></div>
<div class="element"></div>
</div>
Is there an efficient/easy way to do this? I imagine it would look something like this:
$('.element').wrapAll('<div class="wrapper"></div>');
But with a selector that selects the elements in groups of five.
Thanks!