Skip to content

Instantly share code, notes, and snippets.

@jdlich
Created December 8, 2010 00:14
Show Gist options
  • Save jdlich/732686 to your computer and use it in GitHub Desktop.
Save jdlich/732686 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
Number.prototype.times = function(value) {
for (var i = 0; i < this; i++) {
value();
}
}
function wrapEveryFour(children) {
var groupsOfFour = Math.floor(children.length / 4) + 1;
(groupsOfFour).times(function() {
$(children.splice(0,4)).wrapAll('<div class="row"></div>');
});
}
$('#content > section').each(function() {
var children = $(this).children('section');
wrapEveryFour(children);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment