-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (24 loc) · 1.03 KB
/
index.js
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
const btn = document.getElementById('btn');
const container = document.getElementById('container');
const input = document.getElementById('text');
const copy = document.getElementById('copy_btn');
const copyMark = document.getElementById('copy_mark');
const copySvg = document.getElementById('svg');
btn.onclick = () => {
const color1 = Math.floor(Math.random() * 16777215).toString(16);
const color2 = Math.floor(Math.random() * 16777215).toString(16);
container.style.backgroundColor = `linear-gradient(#${color1}, #${color2})`;
console.log((container.style.background = `linear-gradient(#${color1}, #${color2})`));
input.value = `linear-gradient(#${color1}, #${color2})`;
copyMark.classList.remove('copy_mark--active');
copySvg.classList.remove('copy_svg');
input.classList.remove('text--active');
};
copy.onclick = () => {
input.select();
input.contentEditable = true;
document.execCommand('copy');
copyMark.classList.add('copy_mark--active');
copySvg.classList.add('copy_svg');
input.classList.add('text--active');
};