vendredi 10 mai 2019

How to avoid "random" in this jquery function?

How I can avoid background to change randomly? I would like them to change always in order: green, yellow, grey and after that again green, yellow grey...

http://test.fusionidea.com/proba/

$(document).ready(function() {
    var colors = ["green", "yellow", "grey"];
    var rand = Math.floor(Math.random() * colors.length);
    $('.change').css("background-color", colors[rand]);
});




Aucun commentaire:

Enregistrer un commentaire