【问题标题】:How to reset the file button [duplicate]如何重置文件按钮[重复]
【发布时间】:2017-02-15 00:21:10
【问题描述】:

我附上了一张图片。当我尝试单击图像下方的“X”图标时,我可以删除文件,但“选择文件”右侧的文件名仍然显示。谁能告诉我如何重置它。

我正在使用以下代码来删除图像。

$('div').on('click', '.closeDiv', function(e){
            var closest = $(this).closest('td');
            var id = closest.find('div:first');
            $(this).prev().remove();
            $(this).remove();
            closest.find('span:first').html('');
            $('#'+id).val("");
        })

【问题讨论】:

标签: jquery


【解决方案1】:

试试这个:

$('#file_id').val('');
// It will remove the selected file. Use it inside your function.

【讨论】:

    猜你喜欢
    • 2018-06-07
    • 2011-09-01
    • 2019-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多