title: Add file input to form using jQuery
body: <p>I'm pretty new to jQuery and I'm trying to make simple HTML upload page and I want to add new file input to form after selecting some file. I've tried this code</p>
  
  <pre><code>&lt;form id="upload" action="upload.php" method="POST" enctype="multipart/form-data" onchange="addField();"&gt;
  &lt;label for="file"&gt;Soubor:&lt;/label&gt;
  &lt;input type="file" name="files[]" id="file" /&gt;&lt;br /&gt;
  &lt;input type="submit" name="Odeslat" value="Odeslat soubor" /&gt;
  &lt;/form&gt;&lt;/body&gt;
  &lt;script&gt;
  $('#upload').delegate('input[type=file]', 'change', function(){
    alert('Alert');
    addField();
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>and this addField() function</p>
  
  <pre><code>function addField(){
    $('&lt;input type="file" name="files[]" id="file" /&gt;&lt;br /&gt;').insertAfter('#file');
  };
  </code></pre>
  
  <p>But if I run this code, the 3rd input field is inserted after the 1st one instead of after the last field. Is it possible to add input fields after the last file input without using unique ids for these inputs? <a href="http://jsfiddle.net/aHrTd/" rel="noreferrer">http://jsfiddle.net/aHrTd/</a></p>
  
  <p>Thanks for any help.</p>