title: JS Set onClick action to a Button that was create inside a loop
body: <p>How to define the onClick property of the Buttons created inside this loop?.JQuery doesn't seem to work at all for that class. </p>
  
  <pre><code>    for(started somewhrere...
  
          var button = document.createElement('button')
          var div = document.createElement('div')
          var img = document.createElement('img')
              img.src = "../img/download.png"
          var p = document.createElement('p')
              p.appendChild(document.createTextNode("Descargar"))
  
          div.appendChild(img);
          div.appendChild(p);
          button.appendChild(div);
  
          button.onClick = "DOSOMETHINGFFS()"
  
          button.className = "download"
  
       for end somewhere...}
  </code></pre>
  
  <hr>
  
  <pre><code>function DOSOMETHINGFFS(){
      alert("no")
  }
  </code></pre>
  
  <p>BTW JQuery isn't really helping at all</p>
  
  <pre><code>$(".download").click(function() {
      alert("ok")
  });
  </code></pre>