Random Quote Machine div color change problems

Random Quote Machine div color change problems
0.0 0

#1

hello. I am having a ton of trouble getting my div with the id windowQuote to change colors when the new quote button is clicked. the color of the body changes but i cant get the background of the specific div to change. HELP. haha

var windColor = document.getElementById(‘windowQuote’);
function renderHTML(data){
var colArr = [["#123456" , “#d1e5fa”], ["#8f1f19" , “#ea7b75”], ["#868228", “#e9e577”], ["#348628", “#89e977”],["#541961", “#e1bcf5”]];
var colorIndex = Math.floor(Math.random() 5);
var index = Math.floor(Math.random() data.length);
htmlQ = ‘"’ + data[index].quote + ‘"’;
htmlN = data[index].name;
windowQ.innerHTML = htmlQ ;
authorName.innerHTML = htmlN;
document.body.style.background = colArr[colorIndex][0];
document.windColor.style.background = colArr[colorIndex][1];
}


#2

You used wrong property. It’s “backgroundColor” not “background”.
http://www.w3schools.com/jsref/prop_style_backgroundcolor.asp

Also there’s no need for “document” before your “windColor” variable.

Solution

windColor.style.backgroundColor = colArr[colorIndex][1];