I have the following structure, one outer div (#results) and about 20 divs with the class event. I want to group every 3 events and wrap a div called outer around them,
<div id="result">
<div class="event">
<div class="date">8 April</div>
<div class="eventname">my title</div>
<div class="link">my link goes here</div>
</div>
// lots more events here
</div>
Try:
while ($('#result > .event').length > 0) {
$('#result > .event:lt(3)').wrapAll('<div class="wrap"></div>')
}
http://jsfiddle.net/rxxjp/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With