Reputation: 1015
I'm using jQuery uniform plugin for forms. But the problem is, how do I clear the 'file' input?
I am using:
$("[name=radio]").removeAttr("checked");
$.uniform.update(".colorPicker");
for clearing the radio boxes.
Also using,
$("#file_upload").replaceWith("<input type='file' id='file_upload' name='file_upload'>").html();
to clear the file input.
Upvotes: 0
Views: 718
Reputation: 730
let input = $('input[name=file_input]');
input.val('');
$.uniform.update(input);
Works 100%.
Upvotes: 0
Reputation: 152
You can set the value of the field by using val() method of jQuery api. So the code is shown below:
$("#test1").on("click", function(){
$("#test").val("");
});
Upvotes: 0
Reputation: 16764
Try sample HTML
<input type='file' name='item1' id="test" />
<input type='button' name='item2' id='test1' value="Empty"/>
javascript:
$(function(){
$("#test1").on("click", function(){
$("#test").replaceWith('<input type="file" name="item1" id="test"/>');
});
});
demo: http://jsfiddle.net/dYEBW/
Means using your code (Update):
$("#file_upload").replaceWith("<input type='file' id='file_upload' name='file_upload'>");
Upvotes: 1