Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove selected file? #86

Open
LocalHeroPro opened this issue Nov 10, 2020 · 3 comments
Open

How to remove selected file? #86

LocalHeroPro opened this issue Nov 10, 2020 · 3 comments

Comments

@LocalHeroPro
Copy link

How to remove selected file from input?
I try:

 $('selector').val('');

but that only clear label.
How to clear only one input from form?

@AlonsoCauich
Copy link

AlonsoCauich commented Dec 7, 2020

Hi!!! You can try something like that:

function remove_selected(id_input){
   var fileInput = document.getElementById(id_input)
   fileInput.value = ''
   fileInput.dispatchEvent(new Event('change'));
}

remove_selected('file');

@jtsimoes
Copy link

jtsimoes commented Dec 27, 2020

What about using a reset button like this?

var btn = document.getElementById('btnResetForm')
var form = document.querySelector('form')
btn.addEventListener('click', function () {
form.reset()
})

@LocalHeroPro
Copy link
Author

@jtsimoes but your code will reset all form, not only one input ;/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants