The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Shuffle Children

Last updated on:

Nice clean version of a ghetto one that I wrote.

$.fn.shuffleChildren = function() {
    $.each(this.get(), function(index, el) {
        var $el = $(el);
        var $find = $el.children();

        $find.sort(function() {
            return 0.5 - Math.random();




View Demo


  1. web developer
    Permalink to comment#

    this is cool I like it.

  2. Nimesh Chheda
    Permalink to comment#

    Cool, nic1

  3. Steve
    Permalink to comment#

    … and if you want shuffle onload:

    <pre>$(window).load(function() {

    Instead of demo page

    <pre>$(“#shuffle”).click(function() {

    • ryan
      Permalink to comment#

      where would I place this? i am somewhat new to coding…I am using dreamweaver, and I have made a js plugin for the code, but where would I put the ‘usage’ aspect?

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed