forked from swapnilsparsh/30DaysOfJavaScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (21 loc) · 804 Bytes
/
Copy pathscript.js
File metadata and controls
23 lines (21 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let colorOne = document.getElementById('color_one');
let colorTwo = document.getElementById('color_two');
let currentdir = "to top";
let outputcode = document.getElementById('code');
function setdirection(value, _this) {
let direction = document.querySelectorAll('.buttons button');
direction.forEach(e => {
e.classList.remove('active');
});
_this.classList.add('active');
currentdir = value;
}
function generate() {
outputcode.value = `background-image: linear-gradient(${currentdir}, ${colorOne.value}, ${colorTwo.value});`;
document.getElementById('body').style.backgroundImage = `linear-gradient(${currentdir}, ${colorOne.value}, ${colorTwo.value})`;
}
function copy(e) {
e.preventDefault();
outputcode.select();
alert("Code copied to clipboard!");
}