Hello I am a self taught developer and I am trying to use a for() loop with jQuery, but it does not seem to work. I am trying to loop through an array of RGB colors, that are hard coded for now with strings. Here is a snippet below on what I am trying to accomplish. I want each div to contain a diffrent
http://jsfiddle.net/CleverOscarDev/cyztq6m5/
var squares = $(".squares");
var colors = [
"rgb(255, 0, 0)",
"rgb(0, 255, 0)",
"rgb(0, 0, 255)",
"rgb(255, 0, 0)",
"rgb(255, 0, 0)",
"rgb(255, 0, 0)",
]
for (var i = 0; i < squares.length; i++) {
squares[i].style.backgroundColor = colors;
}
squares[i].style.backgroundColor = colorsis assigning the whole array. Instead, you should assigncolor[i]