Skip to content

Instantly share code, notes, and snippets.

@NKid
Last active August 19, 2020 05:07
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 NKid/ffd58143e13b9923facb to your computer and use it in GitHub Desktop.
Save NKid/ffd58143e13b9923facb to your computer and use it in GitHub Desktop.
createDocumentFragment
var ul = document.getElementsByTagName("ul")[0]; // assuming it exists
var docfrag = document.createDocumentFragment();
["IE", "FF", "Safari", "Chrome", "Opera"].forEach(function (e) {
var li = document.createElement("li");
li.textContent = e;
docfrag.appendChild(li);
});
ul.appendChild(docfrag);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment