-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorGenerator.js
More file actions
25 lines (22 loc) · 798 Bytes
/
colorGenerator.js
File metadata and controls
25 lines (22 loc) · 798 Bytes
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
function randomColorGenerater()
{
var values = "0123456789ABCDEF".split('');
var colorValue = '#';
for (var i = 0; i < 6; i++)
{
colorValue += values[Math.floor(Math.random() * 16)];
}
return colorValue;
}
document.getElementById("generate").onclick = function()
{
var colorNum = "#" + document.getElementById("color-num-box").value;
document.getElementById("color-num").innerHTML = colorNum;
document.getElementById("color-box").style.backgroundColor = colorNum;
}
document.getElementById("random-generate").onclick = function()
{
var randomColorNum = randomColorGenerater();
document.getElementById("random-color-num").innerHTML = randomColorNum;
document.getElementById("random-color-box").style.backgroundColor = randomColorNum;
}