Discuss / JavaScript / 感觉有点繁琐

感觉有点繁琐

Topic source

赤_子

#1 Created at ... [Delete] [Delete and Lock User]

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(); }


  • 1

Reply