经过一个夜的奋斗,找到最好用,最简单清除file文本中的value值。
例:
<input name="picPathListLocal" type="file" contentEditable="false" tabindex="78" size="50%" class="textfield1">
<input type="button" name="btnResetpicPathListLocal" size="10%" value="重置"
onclick="picPathListLocal.select();document.execCommand('Delete');" class="button1">
上面方法可以清除,但是不建议使用,换为onclick="document.forms[0].picPathListLocal.outerHTML=document.forms[0].picPathListLocal.outerHTML;" 也可以达到效果。
本文介绍了一种简单有效的方法来清除HTML中file类型输入元素的值。通过更改outerHTML属性,可以实现对已选择文件的重置,这种方法比使用document.execCommand('Delete')更为推荐。
488

被折叠的 条评论
为什么被折叠?



