I have grid of 10 X 10 squares and I am using a random function to assign classes to the squares to give some of them different classes/images upon load.
$.fn.random = function() {
var n = this.eq(Math.floor(Math.random() * this.length));
// window.alert(this.eq(Math.floor(Math.random() * this.length)));
return n;
}
$('a').random().addClass("snowman");
I have 16 of these random assignments.
More often than not, some of the random images are placed on top of each each other and therefore become hidden. I thought about removing all classes of the random piece and then adding the class of ('X') for example,
$('a').random().removeClass().addClass("snowman");
but it didn't work.
Is there any easy way to do this?