Adding file inputs dynamically with jquery?

后端 未结 4 511
萌比男神i
萌比男神i 2021-01-20 00:29

To make my weppage as compatible as possible I will go with the regular file input, the problem is that I need to offer multiple uploads.

My thought is that when the

4条回答
  •  长情又很酷
    2021-01-20 00:35

    You could have a container div which will harbor the new file input fields and a button to add new inputs:

    $('#addFile').click(function() {
        // when the add file button is clicked append
        // a new 
        // to a filesContainer div
        $('#filesContainer').append(
            $('').attr('type', 'file').attr('name', 'someName')
        );
    });
    

提交回复
热议问题