-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuttons.js
More file actions
38 lines (32 loc) · 1.17 KB
/
buttons.js
File metadata and controls
38 lines (32 loc) · 1.17 KB
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
31
32
33
34
35
36
37
38
const buttons=document.querySelectorAll('.my-buttons button')
console.log(buttons.length)
const bodycolor=document.querySelector('body');
console.log(bodycolor.lastChild);
const hcolor=document.querySelector('.info h3');
console.log(hcolor);
const Red=Math.floor(Math.random()*255);
const Green=Math.floor(Math.random()*255);
const Blue=Math.floor(Math.random()*255);
let color=`rgb(${Red},${Green},${Blue})`;
random =function(){
const Red=Math.floor(Math.random()*255);
const Green=Math.floor(Math.random()*255);
const Blue=Math.floor(Math.random()*255);
let color=`rgb(${Red},${Green},${Blue})`;
return color;
}
for(let button of buttons){
console.log(button);
button.addEventListener('click',function(e){console.log(e.target)
e.target.style.color=random();
e.target.style.background=random();
bodycolor.style.background=random()})
// button.addEventListener('click',function(){bodycolor.style.color="green"})
hcolor.textContent=random();
}
mainButton=document.querySelector('.main-button');
console.log(mainButton)
mainButton.addEventListener('click',function (){
bodycolor.style.background=random();
hcolor.textContent=random();
})