Last active
May 2, 2020 19:12
-
-
Save gabydevdev/9519211 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
It worked!! Thanks!!