相关疑难解决方法(0)

清除Internet Explorer中的文件输入框

我的页面上有一个文件上传框和一个清除按钮.当我按下清除按钮时,我希望清除文件上传框中的文本.

以下适用于Firefox,但不适用于IE(文本保留在那里).这有解决方法吗?

$("#clear").click( function() {
    $("#attachment").val("");
    //document.myform.attachment.value = "";
})
Run Code Online (Sandbox Code Playgroud)

HTML:

<form name="myform">
    <input type="file" name="attachment" id="attachment" />
</form>
<br /><button id="clear">Clear Attachment</button>
Run Code Online (Sandbox Code Playgroud)

的jsfiddle

html javascript jquery internet-explorer file-upload

16
推荐指数
3
解决办法
3万
查看次数