title: adding 'click' event listeners in loop
body: <p>Refactoring standard <code>onClick</code> within html tag to listeners ,faced problem with my code:</p>
  
  <pre><code>var td;
      for (var t=1;t&lt;8;t++){
          td = document.getElementById('td'+t);
          if (typeof window.addEventListener==='function'){
                  td.addEventListener('click',function(){
                      console.log(td);
              })}
   }  
  </code></pre>
  
  <p>When <code>td</code> element is clicked on,it's assumed that clicked <code>td</code> with last index from loop,e.g. <code>7</code><br>
  Looks like ,<code>eventListeners</code> been populated for last element in this loop only.<br>
  Loop initialization looks correct.<br>
  Why so happened?</p>
  
  <p>Here is <a href="http://jsfiddle.net/Rt2dw/1/" rel="noreferrer">live code</a></p>