Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> </head> <body> <form> <div> <label>File</label> <br> <input id="fileId" type="file"> </div> <div> <label>Name</label> <br> <input id="textId" type="text" value="File name"> </div> <div> <button id="btn-file-reset-id" type="button">Reset file</button> <button id="btn-text-reset-id" type="button">Reset text</button> </div> </form> <script> $(document).ready(function() { $('#btn-file-reset-id').on('click', function() { $('#fileId').val(''); }); }); $(document).ready(function() { $('#btn-text-reset-id').on('click', function() { $('#textId').val(''); }); }); </script> </body> </html>