Why doesn't remove work?

  • 0
    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 work
    JavaScript Marilyn Evans, Apr 4, 2020

  • 2 Answers
  • 0
    You call a method on a collection
    Anonymous

  • 0
    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 another
    Isabelle Wright

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!