Created
May 11, 2020 18:01
-
-
Save RogelioHIT/721e111a33f5842d4bfeceb4c3383355 to your computer and use it in GitHub Desktop.
Shuffle Divs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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