Skip to content

Instantly share code, notes, and snippets.

@jamiejohnsonkc
Last active September 7, 2021 23:08
Show Gist options
  • Save jamiejohnsonkc/45f42efc71f698b5d6573599bbf783c1 to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/45f42efc71f698b5d6573599bbf783c1 to your computer and use it in GitHub Desktop.
js generate random colors
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function setRandomColor() {
$("#colorpad").css("background-color", getRandomColor());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment