如何重置(清除)文件输入 [英] how to reset (clear) file input

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

问题描述

如何在IE中重置文件输入,我使用以下和它工作在chrome和FF但不是IE



fileInputElement.value =

解决方案

/ div>

如果 fileInputElement fileInputForm 的形式独立存在,您可以:

  window.fileInputForm.reset(); 

否则,您必须将元素替换为克隆:

  fileInputElement.parentNode.replaceChild(
fileInputElement.cloneNode(true),
fileInputElement
);


how can I reset file input in IE, I used the following and it worked in chrome and FF but not IE

fileInputElement.value=""

what's the alternative in IE ?

解决方案

If fileInputElement is on its own in the form fileInputForm, you can do:

window.fileInputForm.reset();

Otherwise for IE you'll have to replace the element with a clone:

fileInputElement.parentNode.replaceChild(
    fileInputElement.cloneNode(true), 
    fileInputElement
);

这篇关于如何重置(清除)文件输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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