在网上搜索了一下,大概有以下三种方法:
1.form.reset();
此操作会清空表单中的其它值,下面有篇文章可以解决这个问题,但我还是觉得很麻烦。
参考:http://liuwei1981.javaeye.com/blog/226651
2.e.outerHTML=e.outerHTML
参考:http://topic.csdn.net/u/20070122/11/d2eb9cf7-ecc3-4a12-81a0-a24e2b0a560e.html
var e=document.getElementById( “FileUpload”);
e.outerHTML=e.outerHTML
火狐好像不支持
3.笨办法,重写这个input
<span id=”upfileSpan”><input name=”upfile” id=”upfile” type=”file” /></span>
function clearUpload(){
document.getElementById(“upfileSpan”).innerHTML=document.getElementById(“upfileSpan”).innerHTML;
}
IE6、IE8、FireFox测试通过