Sometimes, we want to clear an HTML file input with JavaScript.
In this article, we’ll look at how to clear an HTML file input with JavaScript.
How to clear an HTML file input with JavaScript?
To clear an HTML file input with JavaScript, we set its value
property to an empty string.
For instance, we write
document.getElementById("your_input_id").value = "";
to select the file input with getElementById
.
Then we set its value
property to an empty string to clear it.
Conclusion
To clear an HTML file input with JavaScript, we set its value
property to an empty string.