Skip to content

Instantly share code, notes, and snippets.

View onemanparsons's full-sized avatar

onemanparsons

View GitHub Profile
@iMoses
iMoses / jquery.plugin.wrapInGroups.js
Created July 26, 2012 12:21
jQuery Plugin wrapInGroups
/**
* Takes a jQuery collection and wraps each 'groupSize' items with 'wrapHtml'
* Example: $('#Example span').wrapInGroups('<div/>', 4);
* Will wrap every 4 span's inside #Example with a div
* See for yourself: http://jsfiddle.net/M9ZFh/
* Author: iMoses (imoses.g@gmail.com)
*/
(function($) {
$.fn.wrapInGroups = function(wrapHtml, groupSize) {
var selector = this.selector;