-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (24 loc) · 814 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let codeHex = document.querySelector('#btn-color')
let colorDisplay = document.querySelector('#color-code')
let colorHex
let randomColor = () => {
colorHex = "#"
let hexadecimal = "0123456780ABCDEF"
for (let i = 0; i <= 5; i++) {
colorHex = colorHex + hexadecimal[Math.floor(Math.random() * 16)]
}
return colorHex
}
codeHex.addEventListener('click', () => {
document.querySelector("#container").style.backgroundColor = randomColor()
colorDisplay.style.display = "block"
colorDisplay.innerHTML = colorHex
colorDisplay.style.backgroundColor = colorHex
colorDisplay.style.color = "#FFFFFF"
})
const copyClipboard = () => {
copyHex = colorDisplay.innerText
// Copy the text inside the text field
navigator.clipboard.writeText(copyHex)
alert (`Copied the Hex Color ${colorHex}`)
}