Answer the question
In order to leave comments, you need to log in
How to activate input file fields with click()?
Hello, I need to emulate clicking on an input file field using js.
Now I'm trying to figure out this solution.
$(function() {
$("#formUploadBtn").click(function() {
$("#formInput").click();
});
});
<form id="test_form" method="post" action="">
<input type="file" id="formInput"/>
<button id="formUploadBtn">Upload</button>
</form>
Answer the question
In order to leave comments, you need to log in
e May the answer is simple - the button submits the form)
In order that there would be no submit
$(function () {
$("#formUploadBtn").click(function () {
$("#formInput").click();
return false;
});
$('#formInput').change(function () {
$('#test_form').submit();
})
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question