-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (17 loc) · 771 Bytes
/
script.js
File metadata and controls
24 lines (17 loc) · 771 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
let hname = document.querySelector('h3');
let color1 = document.querySelector('.color1');
let color2 = document.querySelector('.color2');
let body = document.getElementById('gardient');
let button = document.getElementById('random');
function backgroundssStyle() {
body.style.background = `linear-gradient(to right, ${color1.value}, ${color2.value})`;
hname.textContent = `${body.style.background};`;
}
function newColor(){
body.style.background = `linear-gradient(to right, ${randomColor()}, ${randomColor()})`;
hname.textContent = `${body.style.background};`;
}
color1.addEventListener('input', backgroundssStyle);
button.addEventListener('click', newColor);
color2.addEventListener('input', backgroundssStyle);
window.onlaod = backgroundssStyle();