<html>
<body>
<button onclick="generateColor()">
Generate New Color
</button>
</body>
</html>
body {
text-align: center;
background-color: hsl(0, 100%, 93%);
}
button {
margin: 40px;
}
function generateColor() {
var randomValue = Math.round(Math.random() * 360);
var colorString = "hsl(" + randomValue + ", 100%, 93%)";
document.body.style.backgroundColor = colorString;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.