Last active
December 14, 2015 02:59
-
-
Save fethica/5017743 to your computer and use it in GitHub Desktop.
A simple jQuery function to change a class every 2 seconds.
This file contains 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
function switchClass(){ | |
var delay = 2000; | |
var colors = new Array ("red", "grey", "green", "blue"); | |
var i = 0; | |
setInterval(function(){ | |
$('span').removeClass(colors[i]); | |
i++; | |
if(i== colors.length) i=0; | |
$('span').addClass(colors[i]); | |
}, delay); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment