How to fire event on file select in jQuery
change()
You can simply use the jQuery change() method to fire an event to do something when the user select any file using the HTML file <input> type box.
<input>
Let's try out an example to understand how this method basically works:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Fire Event on File Select</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $("#myInput").change(function(){ alert("A file has been selected."); }); }); </script> </head> <body> <form> <input type="file" id="myInput"> </form> </body> </html>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Use the jQuery
change()methodYou can simply use the jQuery
change()method to fire an event to do something when the user select any file using the HTML file<input>type box.Let's try out an example to understand how this method basically works:
need an explanation for this answer? contact us directly to get an explanation for this answer