Skip to content

Instantly share code, notes, and snippets.

@dimitrikennedy
Created March 9, 2012 02:16
Show Gist options
  • Save dimitrikennedy/2004629 to your computer and use it in GitHub Desktop.
Save dimitrikennedy/2004629 to your computer and use it in GitHub Desktop.
JavaScript: add random css class from array
var classes = ['1', '2', '3'];
$('').removeClass();
$('').addClass(function(){ return classes[Math.floor(Math.random() * classes.length)]; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment