title: javascript add ondrastart to img
body: <p>I have this code that is supposed to create 10 draggable img elements</p>
  
  <pre><code>var container = document.getElementById("container");
  
              for (var i = 0; i &lt; 10; i++) {
                  var trash = GenerateTrash(i);
                  container.appendChild(trash); 
              }
              function GenerateTrash(i) {
                  var trash = document.createElement("img");
                  trash.src = "crumpled-paper.png";
                  trash.id = i;
                  trash.draggable = true;
                  trash.ondragstart = function () { ev.dataTransfer.setData("dragged-id", ev.target.id); };
                  return trash;
              }
  </code></pre>
  
  <p>However, when I run it through the debugger, the "ondragstart" function simply isn't there. Help ?</p>