I have a web page that has a div element with a colored background.
I want the color to change each time someone loads the page.
I found this snippet of code online which apparently generates a random hexadecimal number:
'#'+Math.floor(Math.random()*16777215).toString(16);
I'm new to JavaScript and so I'm trying to piece together how I implement this.
I assume that I assign a variable to the randomly generated hexadecimal:
bandColor = '#'+Math.floor(Math.random()*16777215).toString(16);
Now I'm not sure whether I use this variabile (bandColor) in my stylesheet or my html.
If it's the html, I'm guessing I do something like this in the JavaScript:
$("#band").html(bandColor);
And then in the html:
<div id="band">
Would appreciate anyone who can point out what I have right / wrong!