I have a series of DIVs on the page (each with the same class). On load, I'd like to randomise the colour of each DIV.
I'd like a colour to be chosen for a given DIV, then a colour chosen for the next one and so on.
I found this post: Apply random color to class elements individually?
I don't understand jquery, however I have begun 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 much appreciated!
--
Code example here: http://jsfiddle.net/ollyf/LmwYP/
And I should also add the random background colour is from a preset/predetermined list of colours.
.jump-response
element and setting the background on the same element on every iteration) ? – Aracelyaraceous