Skip to content

Instantly share code, notes, and snippets.

@TravisL12
Created September 22, 2012 00:13
Show Gist options
  • Save TravisL12/3764627 to your computer and use it in GitHub Desktop.
Save TravisL12/3764627 to your computer and use it in GitHub Desktop.
An attempt at JS
var blogs = [
{"Title" : "Rebuilding shit",
"Post" : "I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. I think progress has been made\. ",
"Footer" : "September 3rd 2012"
},
{"Title" : "Second post containting stuff",
"Post" : "Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. Practice makes perfect\. " ,
"Footer" : "October 2nd 2012"
},
{"Title" : "The third thing I've typed out",
"Post" : "At this point I am trying to determine how a \'for\' loop effects what is drawn on a page\." ,
"Footer" : "December 4th 2012"
}
];
window.addEventListener("DOMContentLoaded", function() {
target = document.getElementById("post-index");
for(var i=0; i<blogs.length; i++) {
var element = document.createElement('li');
element.addEventListener('click', function(event) { alert(event.target +'was clicked'); });
element.appendChild(document.createTextNode(blogs[i]['Title']));
target.appendChild(element);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment