I'm trying to randomize an array of div classes and then fade in different divs (facts) each time a button is clicked. However, what I can't work is how to display a completely different div each time, so that a div is not repeated on click.
My current code is:
$(document).ready(function () {
var facts = Array('.fact1', '.fact2');
$(document).delegate('a.eggbutton', 'click', function () {
$(fact).fadeOut('slow');
var fact = facts[Math.floor(Math.random() * facts.length)];
$(fact).fadeIn('slow');
});
});