var arr = ["JavaScript", "HTML", "CSS"],
list = document.querySelector("#test-list");
var remove = function() {
var result = false;
for (var i = 0; i < list.children.length; i++) {
if (!(arr.indexOf(list.children[i].childNodes[0].nodeValue)+1)) {
list.removeChild(list.children[i]);
return result;
}
}
return !result;
}
while (!remove()) {
remove();
}
赤_子
var arr = ["JavaScript", "HTML", "CSS"], list = document.querySelector("#test-list"); var remove = function() { var result = false; for (var i = 0; i < list.children.length; i++) { if (!(arr.indexOf(list.children[i].childNodes[0].nodeValue)+1)) { list.removeChild(list.children[i]); return result; } } return !result; } while (!remove()) { remove(); }