-
-
Save rmzse/ebe6f9293876396f83ff45d32ecdfd7a to your computer and use it in GitHub Desktop.
add random classes - js
This file contains hidden or 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($){ | |
| $(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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment