title: Event listener not displaying line-through when ticking checkbox of list item
body: <p>I’ve created a function named <code>checkedItems</code>. I want the function to cross an item out each time the check box attached to it is ticked. However, nothing happens when I do so. If someone could point out where I’ve gone wrong in my code and fix it, that would be great.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var elUlList = document.getElementById("ulList");
  var btn = document.getElementById("btn");
  const elInput = document.getElementById("input");
  const footer = document.querySelector("footer");
  const message = document.getElementById("message");
  const elCounter = document.getElementById("counter");
  
  function createListItems() {
    var elements = document.getElementsByTagName('li');
    
    console.log(elements)
    
    var inputValue = elInput.value;
    var newLi = document.createElement("li");
    var input = document.createElement("input")
    
    input.type = "checkbox"
    
    var newText = document.createTextNode(inputValue);
    
    newLi.appendChild(input);
    newLi.appendChild(newText);
    elUlList.appendChild(newLi)
  }
  
  btn.addEventListener("click", createListItems, false);
  elInput.addEventListener("keyup", function(e) {
    if (e.keyCode === 13) {
      e.preventDefault();
      btn.click()
    }
  })
  elInput.addEventListener("mouseover", emptyField, false)
  
  function emptyField() {
    this.value = "";
  }
  
  elUlList.addEventListener("change", checkedItems, false)
  
  function checkedItems() {
    var checkboxes = document.querySelectorAll("input[type=checkbox]")
    var checkboxesArray = Array.from(checkboxes);
    
    console.log(checkboxes.length);
    
    if (checkboxes.length &gt; 1) {
      for (var i = 0; i &lt; checkboxes.length; i++) {
        checkboxes[i].checked
          ? checkboxes[i].classList.toggle("lineThrough")
          : null;
      }
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en" dir="ltr"&gt;
  
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;link rel="stylesheet" href="index.css"&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;div id="message" class=""&gt;&lt;/div&gt;
    &lt;ul id="ulList"&gt;&lt;/ul&gt;
    &lt;button id="btn" type="button" name="button"&gt;click here to add items&lt;/button&gt;
    &lt;input id="input" type="text" name="" value=""&gt;
    &lt;div id="counter" class=""&gt;&lt;/div&gt;
    &lt;footer&gt;&lt;/footer&gt;
    &lt;script src="index.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>