jQuery, random div order

前端 未结 3 2138
别跟我提以往
别跟我提以往 2021-02-04 08:57

I have this jQuery and HTML http://jsfiddle.net/UgX3u/30/

    
3条回答
  •  我寻月下人不归
    2021-02-04 09:32

    var $container = $("div.container");
    $container.html(shuffle($container.children().get()));
    
    function shuffle(o){
        for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
        return o;
    };
    

    Shuffle function found here

    Updated: jsFiddle

提交回复
热议问题