title: Adding event handler (with parameters) to element created using document.createElement
body: <p>In the function below I'm trying to create a dynamic element <em>(textArea)</em>. I'm trying to bind a function <em>(resize)</em> to the text area using <em>textArea.onclick = resize;</em> which works fine.</p>
  
  <p>What I'd like to do is pass a parameter to the resize function (either the generated id or, if possible, the textArea itself)</p>
  
  <pre><code>    function addElement(elm, event) {
          var textArea = document.createElement('textarea');
          var id = Math.random();
          textArea.setAttribute('id', id)
          textArea.setAttribute('cols', 1);
          textArea.setAttribute('rows', 3);
          textArea.onclick = resize;
          elm.appendChild(textArea);
      }
  </code></pre>
  
  <p>if I say <em>textArea.onclick = resize(id);</em> then that just calls the function.</p>
  
  <p>How can i bind the function, and pass a parameter to it?</p>