Reputation: 22323
HTML:
<input type="file" id="flIcon" />
In Jquery:
$('#btnAddNew').click(function(event) {
alert($("#flIcon").attr('file'));
$("div#flIcon").replaceWith("<input type='file' id='flIcon'/>");
});
I see in FireBug when page Load:
<div id="uniform-flIcon" class="uploader">
<input id="flIcon" class=" " type="file" style="opacity: 0;">
<span class="filename" style="-moz-user-select: none;">document-save.png</span>
<span class="action" style="-moz-user-select: none;">Choose File</span>
</div>
I try it from this ref.Clearing <input type='file' /> using jQueryBut its not work for me.Is there any browser compatibility issue or i am missing some thing.Thanks.
Upvotes: 0
Views: 2290
Reputation: 6642
Yes Darin's solution works well.
Alternatively you could also clear by doing this using JQuery..
$('#flIcon').val('');
Upvotes: 0
Reputation: 1039130
Try like this:
<input type="file" id="flIcon" />
<div id="btnAddNew">Clear</div>
and then:
$('#btnAddNew').click(function(event) {
$("#flIcon").replaceWith("<input type='file' id='flIcon'/>").html();
});
Upvotes: 1