Skip to content

Instantly share code, notes, and snippets.

@micha149
Created July 28, 2011 14:33
Show Gist options
  • Save micha149/1111650 to your computer and use it in GitHub Desktop.
Save micha149/1111650 to your computer and use it in GitHub Desktop.
Grouping every 5 elements with jQuery
var childs = $('div.wrapper > div');
childs.filter(':nth-child(5n+1)').each(function(){
$(this).nextAll(':lt(4)')
.andSelf()
.wrapAll('<div/>');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment