We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dbc1afb commit 59aa06bCopy full SHA for 59aa06b
1 file changed
fetch/exercises/fetch_planets.html
@@ -0,0 +1,33 @@
1
+<!DOCTYPE html>
2
+<html>
3
+ <head>
4
+ <title>Fetch Planets</title>
5
+ <script>
6
+ window.addEventListener("load", function(){
7
+ let json = [];
8
+
9
+ fetch("https://handlers.education.launchcode.org/static/planets.json").then(function(response) {
10
+ response.json().then( function(json) {
11
+ const destination = document.getElementById("destination");
12
+ let index = 0;
13
+ destination.addEventListener("click", function() {
14
+ destination.innerHTML = `
15
+ <div>
16
+ <h3>Planet ${json[index].name}</h3>
17
+ <img src=${json[index].image} height=250></img>
18
+ </div>
19
+ `;
20
+ index = (index + 1) % json.length;
21
+ });
22
23
24
25
+ </script>
26
+ </head>
27
+ <body>
28
+ <h1>Destination</h1>
29
+ <div id="destination">
30
+ <h3>Planet</h3>
31
32
+ </body>
33
+</html>
0 commit comments