title: addEventListener Created an Infinite Loop
body: <p>I added an event listener and it created an infinite loop I really don't get what I did wrong.</p>
  
  <p>What happen is it keeps clicking the images by itself </p>
  
  <p>Here's my code:</p>
  
  <pre><code>function attachOnClickEvent(cases,theme,debut,capture){
      var images=document.getElementsByTagName('img');
      for(var i=0;i&lt;images.length;i++){
          images[i].addEventListener("click",x(cases,theme,debut,capture),false);
      }
  };
  
  var x=function(cases,theme,debut,capture){newImage(this,cases,theme,debut,capture);};
  
  function newImage(elem,cases,theme,debut,capture){
      var images=preloadImages(cases,theme);
      var imgTab=document.getElementsByTagName('img');
      var Id=elem.id;
      elem.src=images[randomTab[Id]];
  
  }; 
  </code></pre>
  
  <p>Hope someone can find my mistake.. Thanks!</p>