Simple Jquery Plugin To Randomly change Background Color Of HTML Element

In this tutorial I am going to share Simple JQuery Plugin To Randomly change Background Color Of Body/Div. This tinny jQuery plugin (randomBG) is useful to set random bg color on any html element on each time pageload.

Integrate randomBG Plugin on your website

Libraries

Load latest jQuery core library and the jQuery randomBG plugin’s library on page.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.randombg.js"></script



JS

Apply random bdcolor on whole HTML body or specific HTML element

$(function() {  
   $("body").randombg();
   //  $("#randomBG").randombg();
});

You can also specify the init hex color for the background on first time page load.

$(function() {  
 $("body").randombg({
   color: 'a33e66'
 });
});

See live demo and download source code.

DEMO | DOWNLOAD

Visit official github repository for more information and follow for future updates. Don’t forget to read license for using this plugin in your projects.