-
-
Save triskweline/bf97bcd566af82db0fddb9209aa91f76 to your computer and use it in GitHub Desktop.
Shuffle child elements with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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