现在的位置: 首页 > 综合 > 正文

清空file框中的内容

2014年09月05日 ⁄ 综合 ⁄ 共 408字 ⁄ 字号 评论关闭

两种办法:

1. 

<html>
<head>
</head>
<body>
<form name="myform">
<input type="file" name="ff"/>
<input type="button" value="清空file中的内容" onclick="ff.select();document.execCommand('delete')" >
</form>
</body>
</html>

2.

<html>
<head>
</head>
<body>
<form name="myform">
<input type="file" id="f"/>
<input type="button" value="清空file中的内容" onclick="document.getElementById('f').outerHTML=document.getElementById('f').outerHTML">
</form>
</body>
</html>

抱歉!评论已关闭.