Skip to content

Instantly share code, notes, and snippets.

@jaywon
Last active August 29, 2015 14:17
Show Gist options
  • Save jaywon/d265bb84c7e4ac709647 to your computer and use it in GitHub Desktop.
Save jaywon/d265bb84c7e4ac709647 to your computer and use it in GitHub Desktop.
//get a reference to the main element in your HTML document(DOM)
var mainElement = document.getElementById('main');
for (var i = 0; i < window.geemails.length; i++) {
var x = document.createElement("P");
var t = document.createTextNode(window.geemails[i].sender + " " + window.geemails[i].subject + " " + window.geemails[i].date);
x.appendChild(t);
//append to the main element to attach new element as a child of main instead of document.body
mainElement.appendChild(x);
}
//can do this once outside of the for loop since geemails.length won't change in the for loop so value stays the same
// inbox count
document.getElementById("count").innerHTML = "(" + geemails.length + ")";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment