Last active
March 3, 2023 07:00
-
-
Save jonathanhudak/f4917f23434b8f8b6bf0e55c9c3333b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const div = document.createElement("div"); | |
div.style.padding = "2rem"; | |
div.style.display = "flex"; | |
div.style.justifyContent = "space-between"; | |
div.style.maxWidth = "700px"; | |
const button = document.createElement("button"); | |
const colors = ["indigo", "purple", "gold", "khaki", "aqua"]; | |
function getRandomColor() { | |
return colors[Math.floor(Math.random()*colors.length)]; | |
} | |
button.innerText = "do something"; | |
button.addEventListener("click", () => { | |
div.style.backgroundColor = getRandomColor(); | |
}); | |
div.appendChild(button); | |
document.body.appendChild(div); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment