-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
64 lines (47 loc) · 1.57 KB
/
index.html
File metadata and controls
64 lines (47 loc) · 1.57 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<link rel="stylesheet" href="style.css">
<title>Frontend Mentor | Advice generator app</title>
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
<style>
.attribution {
font-size: 11px;
text-align: center;
}
.attribution a {
color: hsl(228, 45%, 44%);
}
</style>
</head>
<body>
<div class="container">
<div class="card">
<p class="title">advice #81</p>
<p class="quote">“Age is of no importance, unless you are a cheese.”</p>
<img class="separator mobile" src="images/pattern-divider-mobile.svg" alt="">
<img class="separator desktop" src="images/pattern-divider-desktop.svg" alt="">
<button class="change-button" onclick="getQuote()"><img src="images/icon-dice.svg" alt=""></button>
</div>
</div>
<script>
let idx = 1;
const getQuote = () => {
fetch('https://api.adviceslip.com/advice?q=' + idx)
.then(response => response.json())
.then(data => {
document.querySelector('.title').innerHTML = `Advice #${data.slip.id}`;
document.querySelector('.quote').innerHTML = `“${data.slip.advice}”`;
})
.catch((error) => {
console.error('Error:', error);
});
idx++;
}
</script>
</body>
</html>