2 Replies Latest reply on May 21, 2015 3:32 AM by uboss84

# Shuffle a set of  elements with jQuery

how i can use this function in adobe edge....someone can help me please

Shuffle a set of HTML elements with jQuery - JSFiddle

• ###### 1. Re: Shuffle a set of  elements with jQuery

They use the random function here:

var randomNumber = Math.floor (Math.random () * 2);

Replace the 2 with how many numbers you want it to generate between. For example this code will generate a random number between 0 and 2. If you changed it to 10 it would generate a random number between 0 and 10.

So if I was going to build that page, and had 10 squares I would use:

var randomNumber = Math.floor (Math.random () * 2);

if(randomNumber == 0) {

sym.\$("square1").html("1");

sym.\$("square1").html("2");

sym.\$("square1").html("3");

sym.\$("square1").html("4");

sym.\$("square1").html("5");

}

if(randomNumber == 1) {

sym.\$("square1").html("5");

sym.\$("square1").html("4");

sym.\$("square1").html("3");

sym.\$("square1").html("2");

sym.\$("square1").html("1");

}

if(randomNumber == 2) {

sym.\$("square1").html("3");

sym.\$("square1").html("5");

sym.\$("square1").html("2");

sym.\$("square1").html("1");

sym.\$("square1").html("4");

}

I know this isn't a shuffle method like them. But this would be the way I would do it.The more random numbers you have the more possibilities it will be random. I'm sure there is a better alternative to this method though. Easier way I could think of for edge though.

• ###### 2. Re: Shuffle a set of  elements with jQuery

it's not a good solution, i work with over 100 element