Shuffle Children

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. User Avatar
    web developer
    Permalink to comment#

    this is cool I like it.

  2. User Avatar
    Nimesh Chheda
    Permalink to comment#

    Cool, nic1

  3. User Avatar
    Permalink to comment#

    … and if you want shuffle onload:

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

    Instead of demo page

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

    • User Avatar
      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!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.