-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
52 lines (44 loc) · 1.68 KB
/
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
51
52
<head>
<!-- This will show up on the tab in your browser -->
<title>Chuck Norris Joke of the Day</title>
<!-- Import bootstrap framework for styling -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<style>
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background-color: #efefef;
}
.jokes-container {
padding: 25px;
box-shadow: 0 5px 12px rgba(0,0,0,0.4);
background-color: #fff;
color: #333;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container text-center">
<h1>Here's a joke for you from Chuck Norris</h1>
<div class="jokes-container mb-4">
<!-- Result from the API goes in this paragraph -->
<p id="joke-text"></p>
<!-- Placeholder text -->
<small class = "text-muted">The joke is going to go here.</small>
</div>
<button type="button"
class="btn btn-primary" onclick="getJoke()">Give Me One
</button>
</div>
<script>
const getJoke = async () => {
const res = await fetch('https://api.chucknorris.io/jokes/random')
const random_joke = await res.json()
document.querySelector('p#joke-text').innerText = random_joke.value
document.querySelector('small').style.display = 'none'
}
</script>
</body>