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.
45 lines
1.4 KiB
45 lines
1.4 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
<link rel="stylesheet" href="css/bootstrap.min.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 id="nextJoke" class="btn btn-outline-danger">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>
|