title: How to remove a class from an element on an event added with addEventListener?
body: <p>I'm trying to display images only after they load, using JavaScript.</p>
  
  <p>I tried achieving that by adding a class (<em>hidden</em>) to them, then using <em>addEventListener</em>, the class is removed after they load. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>imgs = document.getElementsByTagName('img');
  for (var i = 0; i &lt; imgs.length; i++) {
      imgs[i].classList.add('hidden');
      imgs[i].addEventListener('load', this.classList.remove("hidden"));
  }
  </code></pre>
  
  <p>After reloading the page, the first image disappears, which indicates that the class was added but something went wrong in the next line.
  In the console I get: <strong>Uncaught TypeError: Cannot read property 'remove' of undefined</strong> at that next line.</p>