0

How to clear input file using jQuery?

var reset = function(e) {
  e.wrap('<form>').closest('form').get(0).reset();
  e.unwrap();
}

$('#resetFileButton').click(function(e) {
  reset($('#file'));
  e.preventDefault();
});

$('#resetTextButton').click(function(e) {
  reset($('#text'));
  e.preventDefault();
});
<form>
  <input id="file" type="file">
  <button id="resetFileButton">Reset file</button>
  <br/><br/>
  
  <input id="text" type="text" value="Original">
  <button id="resetTextButton">Reset text</button>
</form>
RUN
add comment
Suggest a different solution or add another example