-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreateDocumentFragment.html
More file actions
33 lines (33 loc) · 956 Bytes
/
createDocumentFragment.html
File metadata and controls
33 lines (33 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div class="append-c">
<div class="append-child"></div>
</div>
<ul id="ul">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</body>
<script type="text/javascript">
var element = document.getElementById('ul'); // assuming ul exists
var fragment = document.createDocumentFragment();
var browsers = ['Firefox', 'Chrome', 'Opera', 'Safari', 'Internet Explorer'];
// browsers.forEach(function (browser) { var li = document.createElement('li'); li.textContent = browser; fragment.appendChild(li); }); element.appendChild(fragment);
var child
var appendC = element.firstChild
debugger
while (child = element.firstChild) {
debugger
console.log(element.children)
fragment.append(child)
console.log(fragment)
}
</script>
</html>