Clear input type file value after cloning it
-
19-10-2022 - |
Pergunta
I am working on a form in which if a user selects a file, it will duplicate that input and append it after the first one. This part works well except since I am using the clone property, it is also copying the value when it adds another input of type file.
I would like to set this cloned input back to the default value of "browse". How can I accomplish this? Any help would be greatly appreciated.
EDIT: This appears to only be happening in Firefox. Chrome and IE do not have this issue.
jQuery:
$('#attach').on("change", "input[type=file]:last", function() {
var item = $(this).clone(true);
var fileName = $(this).val();
if (fileName){
$(this).parent().append("<br />").append(item);
}
});
HTML:
<tr id="FileAttachmentRow">
<td id="attach"><label for="CAT_Custom_2">File Upload</label><br />
<input type="file" name="FileAttachment[]" id="FileAttachment" class="cat_textbox FileAttachment" /></td>
</tr>
Nenhuma solução correta
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow