If i have 10 divs and i want to choose 5 of them randomly and display them in a random order, how can i do that?
This is what im currently using: http://www.dynamicdrive.com/dynamicindex17/randomcontentorder.htm
If i have 10 divs and i want to choose 5 of them randomly and display them in a random order, how can i do that?
This is what im currently using: http://www.dynamicdrive.com/dynamicindex17/randomcontentorder.htm
Put the ten divs in an array, shuffle the array, and show the first five.
You can name your divs some kind like myDiv_0
to myDiv_9
. Then you can generate random numbers between with JavaScript using var randomnumber=Math.floor(Math.random()*10)
. And after that you can get your div by window.getElementById('myDiv_' + randomnumber)
.