Skip to content

Instantly share code, notes, and snippets.

@fethica
Last active December 14, 2015 02:59
Show Gist options
  • Save fethica/5017743 to your computer and use it in GitHub Desktop.
Save fethica/5017743 to your computer and use it in GitHub Desktop.
A simple jQuery function to change a class every 2 seconds.
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