I’m looking for a way to dynamically “click” the browse button of a input type="file". I have a button that contains an onclick event which I’d like to click the browse button of the input type="file", then an onchange event of the input type="file" will submit the form once the file is selected. I’m not sure how to “click” the input type="file" though.
I’m looking for a way to dynamically click the browse button of a input
Share
All you need to do is call the
clickfunction of theinputelement from the desired element’s click handler.Here is a working JSFiddle to show it in action.