100-project-100-days-website/100_projects/21-background-color-change/script.js
2023-03-14 17:22:55 +03:00
Ask

8 lines
224 B
JavaScript

{5c52880637fc6361021bd24c4154a60b039226af true 224 script.js 0xc002e4a150}

const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
document.body.style.background = randomBg();
});
function randomBg() {
return `hsl(${Math.floor(Math.random() * 360)}, 100%, 50%)`;
}