lundi 5 octobre 2015

Pull all elements randomly from an array

I have an array with list items :

var listArray = [];

$("ul li").each(function(){
    listArray.push($(this));
});

var item = listArray[Math.floor(Math.random()*listArray.length)];

item.css({
    "transform":"scale(1)"
});

And I am pulling randomly a element, but just one. i would like to pull all of them randomly one by one OR multiple eg : i have list of images and i want to pop out images randomly one by one or maybe 4 after 4 which could be even better...

if you have a better idea how to do it please tell me.

DEMO : http://ift.tt/1FQ68mN




Aucun commentaire:

Enregistrer un commentaire