There are several <input type='file' />
fields in my file and there are no any html form
s. I want to clear attached files from particular <input type='file' />
. Not from the all fields. I have use $('input').val("");
but it clears all the <input type='file' />
fields. So how I clear the attached files from particular <input type='file' />
field?
var control = $("#mcontrol");
$("#clear").on("click", function() {
$('input').val("");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="mcontrol" /><br>
<input type="file" id="mcontrol2" />
<button id="clear">Clear</button>
Here is the fiddle
Using JavaScript you can do that as follows.
document.getElementById("#control").value = "";