Return to Snippet

Revision: 35034
at November 1, 2010 12:17 by tomsyweb


Initial Code
$.fn.shuffleChildren = function() {�  �  
$.each(this.get(), function(index, el) {�  �  �  �  
var $el = $(el);�  �  �  �  
var $find = $el.children();�  �  �  �  
$find.sort(function() {�  �  �  �  �  �  
return 0.5 - Math.random();�  �  �  �  
});�  �  �  �  
$el.empty();�  �  �  �  
$find.appendTo($el);�  �  
});
};

Initial URL
http://css-tricks.com/snippets/jquery/shuffle-children/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+CSS-TricksSnippets+%28CSS-Tricks+Snippet+Feed%29

Initial Description
Usage:
$(".parent-element").shuffleChildren();

Initial Title
Shuffle children with jQuery

Initial Tags


Initial Language
jQuery