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


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

<script src="//"></script>
<script src="jquery.randombg.js"></script


Apply random bdcolor on whole HTML body or specific HTML element

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

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

$(function() {  
   color: 'a33e66'

See live demo and download source code.


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.