var list = document.getElementById('test-list');
var filterWords = ['JavaScript','HTML','CSS'];
for(let j = 0;j < list.children.length;j++){
//都可以
/*if(filterWords.findIndex(function (x){
return x === list.children[j].innerText;
}) === -1){
list.removeChild(list.children[j]);
j--;
}*/
if(!filterWords.includes(list.children[j].innerText)){
}
Sign in to make a reply
GodKeen粉
var list = document.getElementById('test-list');
var filterWords = ['JavaScript','HTML','CSS'];
for(let j = 0;j < list.children.length;j++){
//都可以
/*if(filterWords.findIndex(function (x){
return x === list.children[j].innerText;
}) === -1){
list.removeChild(list.children[j]);
j--;
}*/
if(!filterWords.includes(list.children[j].innerText)){
list.removeChild(list.children[j]);
j--;
}
}