Skip to content

Commit 34ba357

Browse files
Quinton KornegayQuinton Kornegay
Quinton Kornegay
authored and
Quinton Kornegay
committed
rotating planets
1 parent 9e83dab commit 34ba357

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

fetch/fetch_planets.html

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Fetch Planets</title>
5+
<script>
6+
window.addEventListener("load", function() {
7+
8+
fetch("https://handlers.education.launchcode.org/static/planets.json").then(function(response) {
9+
response.json().then(function(json) {
10+
const destination = document.getElementById("destination");
11+
let index = 0;
12+
destination.addEventListener("click", function(){
13+
destination.innerHTML = `
14+
<div>
15+
<h3>Planet ${json[index].name}</h3>
16+
<img src=${json[index].image} height=250></img>
17+
</div>
18+
`;
19+
index = (index + 1) % json.length;
20+
});
21+
});
22+
});
23+
});
24+
</script>
25+
</head>
26+
<body>
27+
<h1>Destination</h1>
28+
<div id="destination">
29+
<h3>Planet</h3>
30+
</div>
31+
</body>
32+
</html>

0 commit comments

Comments
 (0)