Skip to content

Commit e48ffdf

Browse files
committed
Dad Jokes API Project HTML, CSS and JavaScript
1 parent e2017e8 commit e48ffdf

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

‎78. Dad Jokes/app.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
document.getElementById("btn").addEventListener("click",joke);
2+
3+
asyncfunctionjoke(){
4+
letconfig={
5+
headers: {
6+
Accept: "application/json",
7+
},
8+
};
9+
10+
leta=awaitfetch("https://icanhazdadjoke.com/",config);
11+
letb=awaita.json();
12+
document.getElementById("content").innerHTML=b.joke;
13+
}

‎78. Dad Jokes/index.html‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<htmllang="en">
2+
<head>
3+
<metacharset="UTF-8" />
4+
<metahttp-equiv="X-UA-Compatible" content="IE=edge" />
5+
<metaname="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Dad Jokes</title>
7+
<linkrel="stylesheet" href="style.css" />
8+
</head>
9+
<body>
10+
<divid="container">
11+
<h1>Dad Jokes 😜</h1>
12+
<buttonid="btn" class="btn">Joke</button>
13+
<divid="content"></div>
14+
</div>
15+
16+
<scriptsrc="app.js"></script>
17+
</body>
18+
</html>

‎78. Dad Jokes/style.css‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
body{
2+
background:#77bfa1;
3+
}
4+
5+
h1{
6+
margin: auto;
7+
font-size:10vh;
8+
}
9+
10+
#container{
11+
display: flex;
12+
flex-direction: column;
13+
justify-content: center;
14+
align-items: center;
15+
font-family: sans-serif;
16+
}
17+
18+
#btn{
19+
margin-top:20vh;
20+
border: none;
21+
outline: none;
22+
background: transparent;
23+
color: white;
24+
border:2px solid white;
25+
padding:10px50px;
26+
cursor: pointer;
27+
}
28+
29+
#content{
30+
margin: auto;
31+
padding:4vh;
32+
font-size:1.2rem;
33+
max-width:700px;
34+
margin-top:20px;
35+
}

0 commit comments

Comments
(0)