I would really appreciate some help with getting this random card generator working. The code I'm currently using can be found below, and wasn't written by me (but was provided to use publicly). I know very little about Javascript..
I have a total of 49 cards in a database / collection on my website, and this basically picks 3 of them to display and sets the rest to hidden. However, I have noticed after around 50-100 refreshes that it seems to be picking certain cards more often than others, and too many times for it to be a coincidence. Specifically those at the start of the list in the database.. (Feminine, Masculine, Urgency)
You can see the live example here: https://cosmic-runes.webflow.io/
Not sure how complex of a problem this is to solve, or if it's just a small tweak..
$(document).ready(function() {
var show_limit = 3;
$('.card-flip-item').each(function(){
if ( $(this).index() >= show_limit) {
$(this).addClass('hidden-list-item');
}
});
});
var cards = $(".card-flip-item");
for(var i = 0; i < cards.length; i++){
var target = Math.floor(Math.random() * cards.length -1) + 1;
var target2 = Math.floor(Math.random() * cards.length -1) +1;
cards.eq(target).before(cards.eq(target2));
}