- //
- <input type="file" id="x" /><button onclick="clearf();">clear</button>
- //
- <script type="text/javascript">
- var clearf = function(){
- var dx = document.getElementById('x');
- dx.value = ''; //火狐这样就可以了
- //下面的if段用于IE
- if(document.selection){
- dx.select(); document.selection.clear();
- }
- }; </script>
转载于:https://blog.51cto.com/3475174/814742