Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save triskweline/bf97bcd566af82db0fddb9209aa91f76 to your computer and use it in GitHub Desktop.
Save triskweline/bf97bcd566af82db0fddb9209aa91f76 to your computer and use it in GitHub Desktop.
Shuffle child elements with jQuery
jQuery.fn.shuffleChildren = function(){
var p = this[0];
for (var i = p.children.length; i >= 0; i--) {
p.appendChild(p.children[Math.random() * i | 0]);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment