Skip to content

Instantly share code, notes, and snippets.

@gabydevdev
Last active May 2, 2020 19:12
Show Gist options
  • Select an option

  • Save gabydevdev/9519211 to your computer and use it in GitHub Desktop.

Select an option

Save gabydevdev/9519211 to your computer and use it in GitHub Desktop.
add random classes - js
(function($){
$(document).ready(function() {
var classes = [ 'style1', 'style2', 'style3' ]; // the classes you want to add
$('.item').each(function(i) { // the element(s) you want to add the class to.
$(this).addClass(classes[ Math.floor( Math.random()*classes.length ) ] );
});
});
})(jQuery);
@Moheimen
Copy link
Copy Markdown

It worked!! Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment