Skip to content

Instantly share code, notes, and snippets.

@Shivabeach
Last active June 17, 2021 22:56
Show Gist options
  • Save Shivabeach/f29906c4949ee22b9ba964eca28ddb38 to your computer and use it in GitHub Desktop.
Save Shivabeach/f29906c4949ee22b9ba964eca28ddb38 to your computer and use it in GitHub Desktop.
Create random colors with Javascript
let backg = document.getElementById('content3');//any place you want to display the color
const colors = document.querySelector('.colors'); //just a P to show the color HEX code
function createColor() {
const randl = Math.random().toString(16).substr(2, 6);
let color = `#${randl}`;
colors.innerHTML = color;
backg.style.backgroundColor = color;
}
createColor();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment