-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
50 lines (35 loc) · 1018 Bytes
/
index.html
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
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Quote Generator | JS</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="container">
<p id="quote">Lorem ipsum dolor sit amet consectetur adipisicing elit. Blanditiis adipisci at cum neque quisquam
commffodi mollitia! Commodi.
</p>
<h3 id="author">lorem' author
</h3>
<button id="btn">Get Quote</button>
</div>
<script>
let quote = document.getElementById("quote");
let author = document.getElementById("author");
let btn = document.getElementById("btn");
const url = "https://api.quotable.io/random";
let getQuote = () => {
fetch(url)
.then((data)=>data.json())
.then((item)=>{
quote.innerText=item.content;
author.innerText=item.author;
});
};
window.addEventListener("load", getQuote);
btn.addEventListener("click",getQuote);
</script>
</body>
</html>