This is what I have:
$(function(){
$('.apple').appendTo('.container');
});
Now, lets say I have 20 different divs with class name .apple.
How can I have them append into Container randomly? So every time that I load the page the order would be different.
Thank you in advance!
jsfiddle http://jsfiddle.net/guest271314/d4p39/
You can try below code by getting some
random
value and use it forif / else
conditions :Demo
You may also use like this:
for more details view this
Giving you an approach which can be used for any number of elements.
Generate random numbers between 0 and 1 and based on it, either append or prepend your element
EDITED
You can do something like this:
Use like this: