Skip to content

Instantly share code, notes, and snippets.

@ThomasRettig
Created January 15, 2022 09:38
Show Gist options
  • Save ThomasRettig/ffc87846da3b101f80608a36be4a01a3 to your computer and use it in GitHub Desktop.
Save ThomasRettig/ffc87846da3b101f80608a36be4a01a3 to your computer and use it in GitHub Desktop.
var body = document.getElementById("body")
var colors = ['#97F091', '#91f0e3', '#ffea54', '#e0f1ff', '#c8ffed', '#b0e8f5']; // the colors we'd like to use
body.style.backgroundColor = colours[Math.floor(Math.random() * colours.length)]; // randomly choose a color from the array
@ThomasRettig
Copy link
Author

Also, ensure that the <body> has the id="body" attribute to it, in order for background-color to be appended to it:

<body id="body">
</body>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment