Categories
JavaScript Answers

How to clear an HTML file input with JavaScript?

Spread the love

To clear an HTML file input with JavaScript, we set its value property to an empty string.

For instance, we write

document.querySelector("#input-field").value = "";

to select the file input with querySelector.

Then we set its value property to an empty string to clear the file input.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *