I have a DIV series on the page (each with the same class). When loading, I would like to randomize the color of each DIV.
I would like to choose a color for this DIV, then choose a color for the next, etc.
I found this post: Apply random color to class elements individually?
I donβt understand jquery, however I started by changing the code to reflect the name of the class I am using:
$(document).ready(function() {
$('.main').each(function () {
var hue = 'rgb(' + (Math.floor((256-199)*Math.random()) + 200) + ',' + (Math.floor((256-199)*Math.random()) + 200) + ',' + (Math.floor((256-199)*Math.random()) + 200) + ')';
$(.jump-response).css("background-color", hue);
});
});
Further help would be greatly appreciated!
-
Sample code here: http://jsfiddle.net/ollyf/LmwYP/
And I also have to add a random background color from a predefined / predefined list of colors.
source
share