清空上传控件(<input type="file"/>)值的方法
方法:创建一个新的form,把上传控件临时放过来,再调用这个form的reset方法,完工之后再把上传控件弄回去。这个form无需进入DOM结构便能正常工作,所以不用担心会对界面有任影响。下面给出函数实现,经过验证工作良好,呵呵。
//
清空文件上传框
function
clearFileInput(file){
var
form
=
document.createElement('form'); document.body.appendChild(form);
//
记住file在旧表单中的的位置
var
pos
=
file.nextSibling; form.appendChild(file); form.reset(); pos.parentNode.insertBefore(file,pos); document.body.removeChild(form);}
转载于:https://www.cnblogs.com/tuyile006/archive/2007/07/26/832203.html
相关资源:数据结构—成绩单生成器