The current functionality is generating random numbers for RGB and based on which is setting the RGB colour.
function randomColor(){
r = Math.floor(Math.random() * (256));
g = Math.floor(Math.random() * (256));
b = Math.floor(Math.random() * (256));
jQuery('.bg').css('background-color','rgb('+r+','+g+','+b+')');
jQuery('#ms-tile-color').attr('content','rgb('+r+','+g+','+b+')');
}
jQuery(document).ready(function(){
randomColor();
var t = setInterval(randomColor,5000);
});
function rollBg() {
$('.bg.hidden').css('background', randomColor());
$('.bg').toggleClass('hidden');
}
I would like to create an array something like the array below and pick a random value from this and keep setting the colour.
var colourArray = [
{r: 40, g: 29, b: 45},
{r: 107, g: 107, b: 181},
{r: 78, g: 100 , b: 78}
];
How do I set the values from the array r, g, b
jQuery('.bg').css('background-color','rgb('+r+','+g+','+b+')');
jQuery('#ms-tile-color').attr('content','rgb('+r+','+g+','+b+')');
this is where I am not understanding
Thanks for your help