-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
102 lines (86 loc) · 2.14 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Promies</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body{
height: 100vh;
background-color: #d1d8e0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: sans-serif;
overflow: hidden;
}
.container{
width: 800px;
max-width: 100%;
text-align: center;
padding: 50px 20px;
background-color: white;
border-radius: 50px;
box-shadow: 13px 13px 62px floralwhite;
}
#jokes{
/* line-height: 40%; */
margin: 50px auto;
max-width: 600px;
/* font-size: 30px; */
text-align: center;
letter-spacing: 3px;
text-transform: uppercase;
}
h3{
color: blue;
transform: translateY(-30px);
}
#jokeBtn{
color: yellow;
background-color: black;
border-radius: 20px ;
border: none;
outline: none;
padding: 12px 20px;
transform: translateY(30px);
box-shadow: 1px 6px 10px black;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h3>Best Jokes</h3>
<div id="jokes"> loading...</div>
<button id="jokeBtn">Next</button>
</div>
<script>
const Jokes = document.getElementById('jokes');
const Btn = document.querySelector('#jokeBtn');
let generate = ()=>{
const setHeader = {
headers :{
accept :" application/JSON"
}
}
fetch('https://icanhazdadjoke.com',setHeader)
.then((res)=>res.json())
.then((data)=>{
jokes.innerHTML = data.joke;
}).catch((Error)=>{
console.log("Error")
})
}
Btn.addEventListener('click',generate);
// generate();
</script>
</body>
</html>