title: Adding multiple event listeners dynamically in JavaScript
body: <p>If I have a program that is adding and taking away html elements dynamically and each one of these elements needs to have an event listener is there a way to add the event listener to a variable that's easier than doing it one by one? I wanted to use an array and have each index of the array to have a event listener attached to it but that doesn't seem to work.</p>
  <pre><code>var1 = document.getElementById('name');
  var1.addEventListener(&quot;mousedown&quot;, doMouseDown, false);
  
      
  </code></pre>
  <p>This works fine but I have about 100 elements so I was hoping there is an easier way than creating 100 individual variables. I there is an easier way to do this I would love any suggestions. :)</p>