I would like to implement a shuffle function, I have this piece of code which worked when the images were not in a table –
var a = $("#deck > div").remove().toArray();
for (var i = a.length - 1; i >= 1; i--) {
var j = Math.floor(Math.random() * (i + 1));
var bi = a[i];
var bj = a[j];
a[i] = bj;
a[j] = bi;
}
$("#deck").append(a);
and this is the code – http://jsfiddle.net/kommandoss/YuRpU/39/
any help appreciated, thanks
Here is a working jsiddle. I added ids to the parent divs like id=”0″ … id=”7″. I also added a class=”letter” in order to be able to count the amount of images and use it within the calculation. The code basically just loops through 36 times and switches 2 random letters with one another within 2 random divs:
http://jsfiddle.net/YuRpU/52/