forked from irfanshadikrishad/JavaScript101
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (21 loc) · 782 Bytes
/
script.js
File metadata and controls
24 lines (21 loc) · 782 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
// Fetching Quote
function quote() {
fetch("https://api.quotable.io/random")
.then((res) => res.json())
.then((data) => {
document.getElementById('copy').innerHTML = 'Copy <i class="fa-regular fa-copy"></i>';
document.getElementById("quote").innerHTML = data["content"];
document.getElementById("author").innerHTML = "— " + data["author"];
document.getElementById('tag').innerHTML = data['tags'][0]
});
}
document.getElementById("next").addEventListener("click", quote);
// COPY
function copy() {
navigator.clipboard.writeText(
document.getElementById("quote").innerHTML +
document.getElementById("author").innerHTML
);
document.getElementById("copy").innerHTML =
'Copied <i class="fa-regular fa-circle-check"></i>';
}