<script> function cleanFile(id){ var _file = document.getElementById(id); if(_file.files){ _file.value = ""; }else{ if (typeof _file != "object"){ return null; } var _span = document.createElement("span"); _span.id = "__tt__"; _file.parentNode.insertBefore(_span,_file); var tf = document.createElement("form"); tf.appendChild(_file); document.getElementsByTagName("body")[0].appendChild(tf); tf.reset(); _span.parentNode.insertBefore(_file,_span); _span.parentNode.removeChild(_span); _span = null; tf.parentNode.removeChild(tf); } } </script> <input id="file1" type="file" /> <input type="button" value="清空" onclick="cleanFile('file1')" />
?