Acak Anak-anak - Trik CSS

Anonim
$.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); )); );

Pemakaian

$(".parent-element").shuffleChildren();

Lihat
Fungsi Pen jQuery Shuffle oleh Chris Coyier (@chriscoyier)
di CodePen.