Skip to content

Instantly share code, notes, and snippets.

@ebonneville
Created May 8, 2012 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebonneville/2639544 to your computer and use it in GitHub Desktop.
Save ebonneville/2639544 to your computer and use it in GitHub Desktop.
// get the element we want
var myElement = document.getElementById("myElement");
// get its inner HTML and put it in an array
var myInnerHTML = [myElement.innerHTML];
for(var i = 0; i < 10; i++) {
// add a string to the end of the myInnerHTML array
myInnerHTML.push("some value");
}
// join the array
myInnerHTML = myInnerHTML.join("");
// reassign the element's inner html
myElement.innerHTML = myInnerHTML;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment