Reputation: 1054
I am manually calling the click event of an input type: file.
HTML
<input onChange={this.displayFilePath} className="invisible" type="file" id="logo"/>
JS
$('#logo').click();
If I was NOT calling the click event manually in the javascript, I could capture the file data within the click event method like so:
let file = event.target.files[0];
So my question is: By operating the click event manually, How do I capture the event
it throws so that I can strip off the file?
Thanks in advance.
Upvotes: 0
Views: 189
Reputation: 411
Is this what you mean?
$('#logo').click(function(event) {
console.log(event);
//whatever you want with the event
});
Although asked about click event you could use
$('#logo').on("change", function(event) {
console.log(event);
//whatever you want with the event
});
change will allow you to capture details about the file after it has been selected instead of calling the function when the input button is clicked.
Upvotes: 3