How to clear File Input

前端 未结 11 1068
臣服心动
臣服心动 2020-12-13 05:10

Below is part of the jquery code I have which displays the file input and a \"Clear File\" button.

var $imagefile = $(\'\').attr({
    type: \         


        
11条回答
  •  隐瞒了意图╮
    2020-12-13 06:06

    Another solution if you want to be certain that this is cross-browser capable is to remove() the tag and then append() or prepend() or in some other way re-add a new instance of the input tag with the same attributes.

    $("#fileinput").remove(); $("") .attr({ type: 'file', id: 'fileinput', name: 'fileinput' }) .appendTo($("label[for='fileinput']"));

提交回复
热议问题