100-project-100-days-website/100_projects/21-background-color-change/script.js

8 lines
224 B
JavaScript
Raw Permalink Normal View History

2023-03-14 17:22:55 +03:00
const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
document.body.style.background = randomBg();
});
function randomBg() {
return `hsl(${Math.floor(Math.random() * 360)}, 100%, 50%)`;
}