-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove-nodes.js
More file actions
31 lines (27 loc) · 804 Bytes
/
remove-nodes.js
File metadata and controls
31 lines (27 loc) · 804 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
/* validated with JSLint edition 2017-04-10 (http://jslint.com/)
* no errors reported (JSLint options: Assume… a browser)
*/
/* jsRemoveNodes: algorithms to remove HTML elements
* see https://github.com/Project4Dimensions/jsRemoveNodes
*/
function removeNodes0(parent) {
"use strict";
var a = document.getElementById(parent);
while (a.childNodes[0]) {
a.removeChild(a.childNodes[0]);
}
}
function removeNodes1(parent) {
"use strict";
var a = document.getElementById(parent);
while (a.firstChild) {
a.removeChild(a.firstChild);
}
}
function newNode(parent, text) {
"use strict";
var a = document.getElementById(parent);
var aa = document.createElement("li");
aa.appendChild(document.createTextNode(text));
a.appendChild(aa);
}