I have a file input element as in code below. How would I get the button part of this file input control using jQuery?
<input type="file" name="FILE1" id="FILE1"></input>
I have a file input element as in code below. How would I get the button part of this file input control using jQuery?
<input type="file" name="FILE1" id="FILE1"></input>
that's not possible because file input behavior is under control of the browser and manipulating that causes security-related issues like preventing the file-upload. however you can set the opacity of file input to 0, and create a dummy element instead and trigger the click event for file input by clicking that:
$("#trigger").click(function(e) {
e.preventDefault();
$("input[type='file']").trigger("click");
})
click cross browser (security reasons). Also, changing opacity to 0 shouldnt affect its clicking ability.input[type='file'] an id can prevent security problems.click is actually the only event that works across browsers. change on the other hand has some problems.There are a number of questions and answers on this that cover what you can do with a file input. It's not much, but it is something.
Erick