Skip to content

Instantly share code, notes, and snippets.

@RogelioHIT
Created May 11, 2020 18:01
Show Gist options
  • Save RogelioHIT/721e111a33f5842d4bfeceb4c3383355 to your computer and use it in GitHub Desktop.
Save RogelioHIT/721e111a33f5842d4bfeceb4c3383355 to your computer and use it in GitHub Desktop.
Shuffle Divs
/*
Shuffle divs called .el in a random way
*/
function shuffleAnswers() {
let positions = [];
$(".el").each(function (i) {
positions.push(i);
});
positions.sort(function () {
return 0.5 - Math.random();
});
$(".el").each(function (i) {
$(this).css("order", positions[i]);
});
}
shuffleAnswers();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment