Last active
January 7, 2020 16:27
-
-
Save karen-izuka/d5a48733b2659c041582b3153c162d05 to your computer and use it in GitHub Desktop.
Random Cats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Random Cats</title> | |
<link rel="stylesheet" href="style.css"> | |
<link href="https://fonts.googleapis.com/css?family=Rochester&display=swap" rel="stylesheet"> | |
</head> | |
<body> | |
<h1>Random Cat Generator</h1> | |
<button id="get">Get Cat!</button> | |
<div> | |
<img src="" alt="" id="target"> | |
</div> | |
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#get').click(() => { | |
$.getJSON('https://aws.random.cat/meow') | |
.done((data) => $('#target').attr('src', data.file)) | |
.fail(() => alert('Request not possible')) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 { | |
font-family: 'Rochester', cursive; | |
font-size: 48px; | |
text-align: center; | |
text-rendering: optimizeLegibility; | |
} | |
button { | |
display: block; | |
margin: auto; | |
} | |
img { | |
display: block; | |
margin: auto; | |
} | |
#target { | |
width: 400px; | |
padding-top: 25px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment