Play with background colors on any HTML elements.
- Include
<script src="path/to/your/directory/random-bg-color.js">
OR
<script src="path/to/your/directory/random-bg-color.min.js">- Put
<script>bgColors.apply();</script>By default if no element is given, colors would be applied to <body> tag.You can pass list of elements by their classes or ids or by thier name itself.
e.g.
- Single element
bgColors.targetElements = '#myId'; or bgColors.targetElements = ['#myId'];- Multiple elements
bgColors.targetElements = ['#myId','#anotherId','#onemoreId'];- Mix elements
bgColors.targetElements = ['#myId','.myClass','.anotherClass','span'];You can also pass selected list of colors e.g.
- Multiple colors
bgColors.colors = ['#1abc9c', '#d3d3d3','#ffeeee'];- Only one color
bgColors.colors = '#1abc9c' or bgColors.colors = ['#1abc9c'];- If you want to change colors without page reload set
bgColors.autoChangevaluetrue. e.g.
bgColors.autoChange=true- You can set interval (in miliseconds) if you has set
autoChange true. e.g.
bgColors.autoChangeDelay = 2000;// Only works if autoChange is true. <script type="text/javascript">
bgColors.targetElements = ['.t1','#g1','div'];
bgColors.colors = ['#1abc9c', '#d3d3d3'];
bgColors.apply();</script>