title: javascript NodeList Selector
body: <p>I would like to say thank you in advance for all the help that will be provided so here is my problem.</p>
  <p>I'm trying to make a simple to-do app I'm at the step where I want to be able to delete some items from the list array (every new list item is pushed inside an array) so I add a button to each task to delete the task then I do a querySelectorAll to get all the button then I loop through each button and add an event listeners to run the specific function but it doesn't work I tried the forEach loop the Array. from method move my script tag to the bottom of the file and also to move my querySelectorAll even further below to make sure it catches all the button but nothing seem to work if you guys have any pointer i would appreciate it here is my code</p>
  <p>github gist <a href="https://gist.github.com/mauricefhebert/91eb605b344f00f70bbd3d5deb01af66" rel="nofollow noreferrer">enter link description here</a></p>
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;en&quot;&gt;
    &lt;head&gt;
      &lt;meta charset=&quot;UTF-8&quot; /&gt;
      &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot; /&gt;
      &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; /&gt;
      &lt;title&gt;TODO App&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class=&quot;container&quot;&gt;
        &lt;header class=&quot;header&quot;&gt;&lt;h1 class=&quot;header-title&quot;&gt;To-Do List&lt;/h1&gt;&lt;/header&gt;
        &lt;nav class=&quot;navbar&quot;&gt;&lt;/nav&gt;
        &lt;main class=&quot;main&quot;&gt;
          &lt;label for=&quot;task&quot;&gt;Add a task: &lt;/label&gt;
          &lt;input class=&quot;taskTextInput&quot; type=&quot;text&quot; placeholder=&quot;add a task&quot; /&gt;
          &lt;button class=&quot;addTaskBtn&quot; type=&quot;button&quot;&gt;Add&lt;/button&gt;
          &lt;button class=&quot;clearTaskBtn&quot; type=&quot;button&quot;&gt;Clear&lt;/button&gt;
          &lt;hr /&gt;
          &lt;div class=&quot;taskContainer&quot;&gt;&lt;/div&gt;
        &lt;/main&gt;
        &lt;footer class=&quot;footer&quot;&gt;&lt;/footer&gt;
        &lt;script src=&quot;./script.js&quot; defer&gt;&lt;/script&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>&quot;use strict&quot;;
  const taskList = [];
  const addTaskBtn = document.querySelector(&quot;.addTaskBtn&quot;);
  const taskTextInput = document.querySelector(&quot;.taskTextInput&quot;);
  const taskContainer = document.querySelector(&quot;.taskContainer&quot;);
  let deleteTaskBtn = document.querySelectorAll(&quot;.deleteTaskBtn&quot;);
  
  function addTask(e) {
    e.preventDefault();
    if (taskTextInput.value == &quot;&quot;) return;
    taskContainer.innerHTML = &quot;&quot;;
    taskList.push(taskTextInput.value);
    taskTextInput.value = &quot;&quot;;
    displayTask();
    return (deleteTaskBtn = document.querySelectorAll(&quot;.deleteTaskBtn&quot;));
  }
  addTaskBtn.addEventListener(&quot;click&quot;, addTask);
  
  function displayTask() {
    for (const task in taskList) {
      const listItem = `
      &lt;div class=&quot;task-container&quot;&gt;
          &lt;li class=&quot;task-item&quot;&gt;${taskList[task]}&lt;/li&gt;
          &lt;div class=&quot;task-button&quot;&gt;
              &lt;input class=&quot;toggleTaskBtn&quot; type=&quot;checkbox&quot;/&gt;
              &lt;img src=&quot;./image/delete.png&quot; class=&quot;deleteTaskBtn icon&quot;&gt;&lt;/img&gt;
          &lt;/div&gt;
      &lt;/div&gt;`;
      taskContainer.insertAdjacentHTML(&quot;afterbegin&quot;, listItem);
    }
  }
  function deleteTask() {
    console.log(&quot;hello&quot;);
  }
  //
  deleteTaskBtn.forEach((btn) =&gt; {
    btn.addEventListener(&quot;click&quot;, deleteTask);
  });
  //
  const toggleTaskBtn = document.querySelectorAll(&quot;.toggleTaskBtn&quot;);
  function toggleTask() {}
  
  /*
  1. Add a new item to a array
  2. display the array on the page
  3. add a checkbox when click add a line over the text and move it to the button if unclick remove the line and move it back in the top
  4. add a clear button to clear of completed item
  */
  </code></pre>