如何在使用按钮将文件选择为“无文件选择”后更改<input type =“file”/>的状态或卸载文件

时间:2018-04-25 12:38:04

标签: jquery html

我使用ajax来保存文件,但我想卸载或更改状态到没有选择的文件,换句话说,我想卸载,在我的操作完成后卸载图像。

1 个答案:

答案 0 :(得分:1)

使用

$(function(){
  $("button").click(function(){
    $("input[type='file']").val("");
  });  
});

例如

&#13;
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="file">
<button>reset</button>
&#13;
{{1}}
&#13;
&#13;
&#13;