如何重置<输入类型=“文件"> [英] how to reset &lt;input type = &quot;file&quot;&gt;

查看:36
本文介绍了如何重置<输入类型=“文件">的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VS2012 和 Javascript 开发 Metro 应用

I am developing a metro app with VS2012 and Javascript

我想重置我的文件输入的内容:

I want to reset the contents of my file input:

<input type="file" id="uploadCaptureInputFile" class="win-content colors" accept="image/*" />

我该怎么做?

推荐答案

@dhaval-marthak 在评论中发布的 jQuery 解决方案显然有效,但是如果您查看实际的 jQuery 调用,很容易看出 jQuery 正在做什么,只需将 value 属性设置为空字符串.因此,在纯"JavaScript 中,它将是:

The jQuery solution that @dhaval-marthak posted in the comments obviously works, but if you look at the actual jQuery call it's pretty easy to see what jQuery is doing, just setting the value attribute to an empty string. So in "pure" JavaScript it would be:

document.getElementById("uploadCaptureInputFile").value = "";

这篇关于如何重置<输入类型=“文件">的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆