A lightweight plugin that changes the class on the block without repeating.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dest
src
.babelrc
.gitignore
LICENSE
README.md
gulpfile.babel.js
index.html
package.json

README.md

randomClassName

A lightweight plugin that changes the class on the block without repeating.

Usage

Include the plugin.

<script src="path/to/randomClassName.min.js"></script>

...or include jQuery and the plugin

<script src="path/to/jquery.js"></script>
<script src="path/to/randomClassName.min.js"></script>

Finally, initialize the plugin.

document.querySelector('body').randomClassName({
    classNames: ['purple', 'blue', 'pink', 'lightblue'],
    prefix: 'theme--'
});

...or jQuery

$('body').randomClassName({
    classNames: ['purple', 'blue', 'pink', 'lightblue'],
    prefix: 'theme--'
});

Options

  • classNames: (type: Array, default []) Array of classes to be selected in random order.

  • prefix: (type: String, default '') The prefix that will be added before the class.

  • suffix: (type: String, default '') The suffix that will be added after the class.

  • repeat: (type: Boolean, default false) Whether to repeat the previous class.