Skip to content

Instantly share code, notes, and snippets.

@haarts
Created May 18, 2016 21:13
Show Gist options
  • Save haarts/90207ba2fe77752b83b39fee72f63cf9 to your computer and use it in GitHub Desktop.
Save haarts/90207ba2fe77752b83b39fee72f63cf9 to your computer and use it in GitHub Desktop.
<html>
<body>
<ul id="list">
<ul/>
<script type="text/javascript">
var list = document.querySelector("#list");
function createListItem(show) {
var link = document.createElement("a");
link.setAttribute("href", show.url);
var linkText = document.createTextNode(show.name);
link.appendChild(linkText);
var item = document.createElement("li");
item.appendChild(link);
return item;
}
fetch('shows.json').then(function(response) {
return response.json();
}).then(function(shows) {
for (show of shows) {
list.appendChild(createListItem(show));
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment