On 6 sep, 09:02, GianCarlo Mingati <[EMAIL PROTECTED]>
wrote:
> ok, it is better to have the images in an array, and then construct
> the list.
> But is there a way with jquery of changing the order of a list?
> GC

Here is the jQuery method version:

jQuery.fn.extend({ scramble :  function() {
    var i = this.size();
    if (!i) return this;
    while (--i) {
        var j = Math.floor(Math.random() * (i+1));
        var tmp1 = this.slice(i, i+1);
        this.slice(j, j+1).after(tmp1).insertAfter(tmp1);
    }
    return this;
}});

$(document).ready(function() { $('#ul li').scramble(); });

Renaud Drousies


Reply via email to