Last active
November 15, 2018 08:44
-
-
Save joseluisq/bfc7e313489fc6fb1e8b to your computer and use it in GitHub Desktop.
Shuffle child elements with jQuery
This file contains hidden or 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