Created
January 28, 2015 08:38
-
-
Save appkr/282740cb6cffd4a9aa5f to your computer and use it in GitHub Desktop.
JavaScript DocumentFragment // source http://jsbin.com/yayoni
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="JavaScript DocumentFragment" /> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<h1>Knights of the Week !</h1> | |
<ul id="kotwList"></ul> | |
<script id="jsbin-javascript"> | |
var list = document.getElementById("kotwList"), | |
kotw = [ | |
"Jenna Rangespike", | |
"Neric Farthing", | |
"Darkin Stonefield" | |
], | |
element, | |
fragment = document.createDocumentFragment(); | |
for (var i = 0, x = kotw.length; i < x; i++) { | |
element = document.createElement("li"); | |
element.appendChild(document.createTextNode(kotw[i])); | |
fragment.appendChild(element); | |
} | |
list.appendChild(fragment); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var list = document.getElementById("kotwList"), | |
kotw = [ | |
"Jenna Rangespike", | |
"Neric Farthing", | |
"Darkin Stonefield" | |
], | |
element, | |
fragment = document.createDocumentFragment(); | |
for (var i = 0, x = kotw.length; i < x; i++) { | |
element = document.createElement("li"); | |
element.appendChild(document.createTextNode(kotw[i])); | |
fragment.appendChild(element); | |
} | |
list.appendChild(fragment);</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = document.getElementById("kotwList"), | |
kotw = [ | |
"Jenna Rangespike", | |
"Neric Farthing", | |
"Darkin Stonefield" | |
], | |
element, | |
fragment = document.createDocumentFragment(); | |
for (var i = 0, x = kotw.length; i < x; i++) { | |
element = document.createElement("li"); | |
element.appendChild(document.createTextNode(kotw[i])); | |
fragment.appendChild(element); | |
} | |
list.appendChild(fragment); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment