-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (18 loc) · 717 Bytes
/
script.js
File metadata and controls
24 lines (18 loc) · 717 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
const color=document.querySelectorAll(".color");
const border=document.querySelectorAll(".border");
const getRandomNumber = (maxNum) => {
return Math.floor(Math.random() * maxNum);
};
const getRandomColor = () => {
const h = getRandomNumber(360);
const s = getRandomNumber(100);
const l = getRandomNumber(100);
return `hsl(${h}deg, ${s}%, ${l}%)`;
};
const setColor = () => {
const randomColor = getRandomColor();
color.forEach(element=>{element.style.color = randomColor;})
color.forEach(element=>{element.style.color = randomColor;})
border.forEach(element=>{element.style.borderLeft=`1px solid ${randomColor}`;})
};
document.getElementById("name").addEventListener('click',setColor);