Skip to content

Instantly share code, notes, and snippets.

@karen-izuka
Last active January 7, 2020 16:27
Show Gist options
  • Save karen-izuka/d5a48733b2659c041582b3153c162d05 to your computer and use it in GitHub Desktop.
Save karen-izuka/d5a48733b2659c041582b3153c162d05 to your computer and use it in GitHub Desktop.
Random Cats
<!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>
$('#get').click(() => {
$.getJSON('https://aws.random.cat/meow')
.done((data) => $('#target').attr('src', data.file))
.fail(() => alert('Request not possible'))
});
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