I have a problem with random positions. I make a script that set <li> random on the page. You can see it here: Click here
But the problem is. That the items overlap. I want make this script with a array. I would like an array with fixed positions. There are always 8 items. And these eight items, all have one fixed position.
How can I make this? How can I make a array with fix positions?
Here my code:
var images = [];
function init() {
$('.friend-selection li > div').each(function(){
var id = this.id;
var img = $('#img_' + id);
var randomTop = 400*Math.random(); //random top position
var randomLeft = 500*Math.random()+1; //random left position
$("#parent_" + id).css({ //apply the position to parent divs
top : randomTop,
left : randomLeft
});
});
};
init();