我正在使用VS2012和Javascript开发Metro应用程序我想重置文件输入的内容:<input type="file" id="uploadCaptureInputFile" class="win-content colors" accept="image/*" />我应该怎么做?
3 回答

MMMHUHU
TA贡献1834条经验 获得超8个赞
发布的jQuery解决方案显然有效,但是如果您查看实际的jQuery调用,则很容易看到jQuery在做什么,只需将value属性设置为空字符串即可。因此,在“纯” JavaScript中,它将是:
document.getElementById("uploadCaptureInputFile").value = "";

白猪掌柜的
TA贡献1893条经验 获得超10个赞
这是最好的解决方案:
input.value = ''
if(!/safari/i.test(navigator.userAgent)){
input.type = ''
input.type = 'file'
}
在所有答案中,这是最快的解决方案。没有输入克隆,没有表格复位!
我在所有浏览器中都对其进行了检查(它甚至具有IE8支持)。
添加回答
举报
0/150
提交
取消