-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday13.html
More file actions
61 lines (45 loc) · 1.19 KB
/
Copy pathday13.html
File metadata and controls
61 lines (45 loc) · 1.19 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE HTML>
<html>
<head>
<title>day 13</title>
<script src="jquery_v1.6.2.js"></script>
<script src="functions.js"></script>
<script>
// Read some documentation for appendChild (http://developer.mozilla.org/en/DOM/element.appendChild)
// Write code to loop through a document and move all <li>’s that are inside <ul>’s with a class of source to a single <ul> in the document with an id of target. You must then delete all empty <ul>’s.
var gatherSource = {
deleteNodes: function() {
// **** delete nodes not done
},
init: function() {
var target = document.getElementById('target');
var source = $('.source li'); // fuck the old way of getClassName
var bucket = [];
for (var i=0; i < source.length; i++) {
bucket.push(source[i]);
};
console.log(bucket);
for (var i=0; i < bucket.length; i++) {
target.appendChild(bucket[i]);
}
}
}
</script>
</head>
<body id="body">
<ul id="target">
<li>something</li>
</ul>
<ul class="source">
<li>something</li>
<li>something else</li>
</ul>
<ul class="source">
<li>another</li>
<li>something other</li>
</ul>
<script>
gatherSource.init();
</script>
</body>
</html>