You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Chuck Norris Jokes</title>
|
|
<link rel="stylesheet" href="css/bootstrap.css">
|
|
<style>
|
|
.card {
|
|
box-shadow: 0 20px 20px rgba(0,0,0,0.5);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container text-center">
|
|
<h1 class="display-2">Random Chuck Norris Jokes</h1>
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8">
|
|
<div class="card mt-5">
|
|
<div class="card-body">
|
|
<p class="fs-4" id="joke"></p>
|
|
<button class="btn btn-danger" id="nextJoke">Next Joke</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
const jokeText = document.getElementById("joke")
|
|
const nextJokeBtn = document.getElementById("nextJoke")
|
|
|
|
function getJoke(){
|
|
fetch("https://api.chucknorris.io/jokes/random")
|
|
.then(response => response.json())
|
|
.then(data => {jokeText.textContent = data.value;})
|
|
}
|
|
nextJokeBtn.addEventListener("click",getJoke);
|
|
getJoke();
|
|
</script>
|
|
<script src="js/bootstrap.bundle.js"></script>
|
|
</body>
|
|
</html>
|