How to access the input elements created by jquery

advertisements

I want to create an upload form, wich always presents a new file input, when filled out. I tried to make this work by creating new inputs but it just works once. Here is the code:

<head><script type="text/javascript" src="jquery-1.7.2.min.js"></script></head>
<body><form>
  <div id="to"></div>
  ---
  <div id="from"><input type="file" class="new"></div>
</form>
<script type="text/javascript">
  $('.new').change(function() {
    $('.new').appendTo('#to').removeClass('new');
    $('#from').append('<input type="file" class="new">');
  });
</script>
</body>

Thanks for your help.


<script type="text/javascript">
  $('.new').live('change',function() {
    $('.new').appendTo('#to').removeClass('new');
    $('#from').append('<input type="file" class="new">');
  });
</script>