Skip to content

Instantly share code, notes, and snippets.

@standa
Created April 22, 2014 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save standa/11172219 to your computer and use it in GitHub Desktop.
Save standa/11172219 to your computer and use it in GitHub Desktop.
Insert input file dynamically using javascript
// works on jQuery 1.9+
$(document).on('change', '.soubor', function () {
if ($(this).val() != '') {
var id = $('.soubor').length + 1;
$('<input>', {type: 'file', name: 'soubor'+id, id: 'soubor'+id, 'class': 'soubor form-control'})
.insertAfter($('.soubor').last());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment