Why doesn't remove work?
-
deleteButton.onclick = function() { var allComplete = document.querySelectorAll('.complete'); for (let i = 0; i < allComplete.length; i++) { allComplete.remove(); } };
You need to remove all elements with the complete class on click, only remove does not workJavaScript Marilyn Evans, Apr 4, 2020 -
You call a method on a collectionAnonymous
-
deleteButton.onclick = function() {
var allComplete = document.querySelectorAll('.complete');
for (let i = 0; i < allComplete.length; i++) {
allComplete[i].remove();
}
};
Please explain why you use var in one case, and let in anotherIsabelle Wright
2 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!