Home  >  Article  >  Web Front-end  >  将input file的选择的文件清空的两种解决方案_javascript技巧

将input file的选择的文件清空的两种解决方案_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:19:261332browse

上传文件时,选择了文件后想清空文件路径,搜索了一下,用两种方法解决

复制代码 代码如下:



第一种:
复制代码 代码如下:

var obj = document.getElementById('fileupload') ;
obj.select();
document.selection.clear();

第二种:
复制代码 代码如下:

var obj = document.getElementById('fileupload') ;
obj.outerHTML=obj.outerHTML;
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn