Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Last active November 15, 2018 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joseluisq/bfc7e313489fc6fb1e8b to your computer and use it in GitHub Desktop.
Save joseluisq/bfc7e313489fc6fb1e8b 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